mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 06:57:02 +08:00
Ionic tool - write template folder correctly.
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
var fs = require('fs'),
|
var fs = require('fs'),
|
||||||
|
ncp = require('ncp').ncp,
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
wrench = require('wrench'),
|
|
||||||
argv = require('optimist')
|
argv = require('optimist')
|
||||||
.usage('Usage: ionic appname')
|
.usage('Usage: ionic appname')
|
||||||
.argv;
|
.argv;
|
||||||
@ -21,9 +21,17 @@ Ionic.prototype = {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_fail: function(msg) {
|
||||||
|
process.stderr.write(msg + '\n');
|
||||||
|
process.exit(1);
|
||||||
|
},
|
||||||
|
|
||||||
_writeTemplateFolder: function() {
|
_writeTemplateFolder: function() {
|
||||||
wrench.copyDirRecursive('template', this.appName, function(err, curFiles) {
|
console.log('Copying template to', this.targetPath);
|
||||||
console.log(curFiles);
|
ncp('template', this.appName, function(err) {
|
||||||
|
if(err) {
|
||||||
|
this._fail('Unable to build starter folder', err);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -38,7 +46,7 @@ Ionic.prototype = {
|
|||||||
return response[0].trim();
|
return response[0].trim();
|
||||||
},
|
},
|
||||||
|
|
||||||
_checkTargetPath: function() {
|
_checkTargetPath: function() {
|
||||||
if(fs.existsSync(this.targetPath)) {
|
if(fs.existsSync(this.targetPath)) {
|
||||||
var resp = this._ask('The ' + this.targetPath + ' directory already exists. Overwrite files? (y/n)')
|
var resp = this._ask('The ' + this.targetPath + ' directory already exists. Overwrite files? (y/n)')
|
||||||
if(resp === 'y') {
|
if(resp === 'y') {
|
||||||
@ -48,7 +56,7 @@ Ionic.prototype = {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
run: function() {
|
run: function() {
|
||||||
if(this._checkArgs() === false) {
|
if(this._checkArgs() === false) {
|
||||||
return this._printUsage();
|
return this._printUsage();
|
||||||
|
|||||||
Reference in New Issue
Block a user