mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-06 22:29:44 +08:00
Start task in own task
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
http://ionicframework.com/
|
http://ionicframework.com/
|
||||||
|
|
||||||
A utility for starting and administering Ionic based mobile app projects.
|
A utility for starting and administering Ionic based mobile app projects.
|
||||||
Licensed under the Apache 2.0 license. See LICENSE For mroe.
|
Licensed under the Apache 2.0 license. See LICENSE For more.
|
||||||
|
|
||||||
Copyright 2013 Drifty (http://drifty.com/)
|
Copyright 2013 Drifty (http://drifty.com/)
|
||||||
*/
|
*/
|
||||||
@ -33,11 +33,7 @@ Ionic.prototype = {
|
|||||||
}
|
}
|
||||||
var taskName = argv._[0];
|
var taskName = argv._[0];
|
||||||
|
|
||||||
var task = this._getTaskWithName(taskName);
|
return this._getTaskWithName(taskName);
|
||||||
|
|
||||||
return {
|
|
||||||
task: task
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_getTaskWithName: function(name) {
|
_getTaskWithName: function(name) {
|
||||||
@ -66,16 +62,6 @@ Ionic.prototype = {
|
|||||||
process.stdout.write('| / \\ |\\ | | / `\n' + '| \\__/ | \\| | \\__,\n\n');
|
process.stdout.write('| / \\ |\\ | | / `\n' + '| \\__/ | \\| | \\__,\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
// Prompt the user for a response
|
|
||||||
ask: function(question) {
|
|
||||||
var response;
|
|
||||||
|
|
||||||
process.stdout.write(question + ' ');
|
|
||||||
process.stdin.resume();
|
|
||||||
response = fs.readSync(process.stdin.fd, 100, 0, "utf8");
|
|
||||||
process.stdin.pause();
|
|
||||||
return response[0].trim();
|
|
||||||
},
|
|
||||||
_loadTaskRunner: function(which) {
|
_loadTaskRunner: function(which) {
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -86,7 +72,10 @@ Ionic.prototype = {
|
|||||||
return this._printGenericUsage();
|
return this._printGenericUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Running', task.task.title, 'task...')
|
console.log('Running', task.title, 'task...')
|
||||||
|
|
||||||
|
var taskObj = new task.task();
|
||||||
|
taskObj.run(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
fail: function(msg) {
|
fail: function(msg) {
|
||||||
|
|||||||
@ -12,9 +12,16 @@ IonicStartTask.HELP_LINE = 'Start a new Ionic project with the given name.';
|
|||||||
|
|
||||||
IonicStartTask.prototype = new IonicTask();
|
IonicStartTask.prototype = new IonicTask();
|
||||||
|
|
||||||
|
IonicStartTask.prototype._printUsage = function() {
|
||||||
|
process.stderr.write('ionic start appname\n');
|
||||||
|
}
|
||||||
|
|
||||||
IonicStartTask.prototype.run = function(ionic) {
|
IonicStartTask.prototype.run = function(ionic) {
|
||||||
this.appName = argv._[0];
|
if(argv._.length < 2) {
|
||||||
|
ionic.fail('No app name specified');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.appName = argv._[1];
|
||||||
this.targetPath = path.resolve(this.appName);
|
this.targetPath = path.resolve(this.appName);
|
||||||
|
|
||||||
// Make sure to create this, or ask them if they want to override it
|
// Make sure to create this, or ask them if they want to override it
|
||||||
@ -37,5 +44,15 @@ IonicStartTask.prototype._writeTemplateFolder = function() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
IonicStartTask.prototype._checkTargetPath = function() {
|
||||||
|
if(fs.existsSync(this.targetPath)) {
|
||||||
|
var resp = this.ask('The ' + this.targetPath + ' directory already exists. Overwrite files? (y/n)')
|
||||||
|
if(resp === 'y') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
exports.IonicStartTask = IonicStartTask;
|
exports.IonicStartTask = IonicStartTask;
|
||||||
@ -1,7 +1,19 @@
|
|||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
var IonicTask = function() {
|
var IonicTask = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
IonicTask.prototype = {
|
IonicTask.prototype = {
|
||||||
|
// Prompt the user for a response
|
||||||
|
ask: function(question) {
|
||||||
|
var response;
|
||||||
|
|
||||||
|
process.stdout.write(question + ' ');
|
||||||
|
process.stdin.resume();
|
||||||
|
response = fs.readSync(process.stdin.fd, 100, 0, "utf8");
|
||||||
|
process.stdin.pause();
|
||||||
|
return response[0].trim();
|
||||||
|
},
|
||||||
run: function(ionic) {
|
run: function(ionic) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user