You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/12/11 23:51:30 UTC
git commit: bin/create check for shelljs/elementtree
Updated Branches:
refs/heads/master 7f4356339 -> 78848046e
bin/create check for shelljs/elementtree
Project: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/commit/78848046
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/tree/78848046
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/diff/78848046
Branch: refs/heads/master
Commit: 78848046e7a9c369d9b14f3c4d49d1a705eedc62
Parents: 7f43563
Author: Maxim Ermilov <ma...@canonical.com>
Authored: Wed Dec 11 18:33:36 2013 +0400
Committer: Maxim Ermilov <ma...@canonical.com>
Committed: Wed Dec 11 18:37:47 2013 +0400
----------------------------------------------------------------------
bin/create | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/78848046/bin/create
----------------------------------------------------------------------
diff --git a/bin/create b/bin/create
index a5fbf45..aee9760 100755
--- a/bin/create
+++ b/bin/create
@@ -21,9 +21,7 @@
var path = require('path');
var args = process.argv;
var ROOT = path.join(__dirname, '..');
-var shell = require('shelljs');
var fs = require('fs');
-var et = require('elementtree');
function help() {
console.log('Usage: ' + path.relative(process.cwd(), path.join(ROOT, 'bin', 'create')) + ' <path_to_new_project> <package_name> <project_name>');
@@ -34,6 +32,24 @@ function help() {
}
function create(project_path, package_name, project_name, project_template_dir) {
+ try {
+ require.resolve("shelljs");
+ require.resolve("elementtree");
+ } 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 shelljs elementtree', 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);
+ });
+ }
+
// Check if project already exists
if(fs.existsSync(project_path)) {
console.error('Project already exists! Delete and recreate');
@@ -43,11 +59,8 @@ function create(project_path, package_name, project_name, project_template_dir)
shell.cp('-r', path.join(ROOT, '*'), path.join(project_path, 'build'));
shell.cp('-r', path.join(ROOT, 'bin/build/*'), path.join(project_path, 'cordova'));
shell.cp('-r', path.join(ROOT, 'xml/config.xml'), project_path);
- // TODO:TAREGET API
shell.cd(project_path);
-// console.log(project_path + "|" + project_name + "|" + project_template_dir + "|" + ROOT);
-//throw new Error();
}
if(args.length < 3 || (args[2] == '--help' || args[2] == '/?' || args[2] == '-h' ||