mirror of
https://github.com/apache/cordova-android.git
synced 2026-04-23 00:00:09 +08:00
Fix for cli with new node scripts
This commit is contained in:
+30
-9
@@ -18,15 +18,36 @@
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
var create = require('./lib/create');
|
||||
var path = require('path');
|
||||
var args = process.argv;
|
||||
|
||||
// Support basic help commands
|
||||
if(args.length < 3 || (args[2] == '--help' || args[2] == '/?' || args[2] == '-h' ||
|
||||
args[2] == 'help' || args[2] == '-help' || args[2] == '/help')) {
|
||||
create.help();
|
||||
} else {
|
||||
create.run(args[2], args[3], args[4]);
|
||||
process.exit(0);
|
||||
try {
|
||||
require.resolve("shelljs");
|
||||
create();
|
||||
} catch(e) {
|
||||
console.log('Shelljs module was not found, running \'npm install\'.....');
|
||||
var exec = require('child_process').exec;
|
||||
var cwd = process.cwd();
|
||||
process.chdir(__dirname);
|
||||
exec('npm install', function (error, stdout, stderr) {
|
||||
if (error !== null) {
|
||||
console.error('ERROR : running \'npm install\' is npm installed? ' + error);
|
||||
console.error(stderr);
|
||||
process.exit(error.code);
|
||||
}
|
||||
process.chdir(cwd);
|
||||
create();
|
||||
});
|
||||
}
|
||||
|
||||
function create() {
|
||||
var create = require('./lib/create');
|
||||
// Support basic help commands
|
||||
if(args.length < 3 || (args[2] == '--help' || args[2] == '/?' || args[2] == '-h' ||
|
||||
args[2] == 'help' || args[2] == '-help' || args[2] == '/help')) {
|
||||
create.help();
|
||||
} else {
|
||||
create.run(args[2], args[3], args[4]);
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user