From d851397dd08d4b412a78a980ca39e72ab6ff6ad4 Mon Sep 17 00:00:00 2001 From: Justin SB Date: Wed, 10 Sep 2014 15:52:23 -0700 Subject: [PATCH 1/5] Make error message when failing to run process more obvious --- tools/commands-cordova.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/commands-cordova.js b/tools/commands-cordova.js index da541b77e7..0f8c15a9fc 100644 --- a/tools/commands-cordova.js +++ b/tools/commands-cordova.js @@ -98,8 +98,17 @@ var execFileSyncOrThrow = function (file, args, opts) { { "WAREHOUSE_DIR": tropo.root }); var childProcess = execFileSync(file, args, opts); - if (! childProcess.success) - throw new Error('Failed to run ' + file + '\n' + childProcess.stderr + '\n\n' + childProcess.stdout); + if (! childProcess.success) { + // XXX: Include args + var message = 'Error running ' + file; + if (childProcess.stderr) { + message = message + "\n" + childProcess.stderr + "\n"; + } + if (childProcess.stdout) { + message = message + "\n" + childProcess.stdout + "\n"; + } + throw new Error(message); + } return childProcess; }; From 861697ea28e5c67e08e61db8252423a36403ba45 Mon Sep 17 00:00:00 2001 From: Justin SB Date: Wed, 10 Sep 2014 15:53:27 -0700 Subject: [PATCH 2/5] Don't include the message when we fail to install the android bundle The message just says "failed to run bash; stdout & stderr have been piped --- tools/commands-cordova.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/commands-cordova.js b/tools/commands-cordova.js index 0f8c15a9fc..952eca99db 100644 --- a/tools/commands-cordova.js +++ b/tools/commands-cordova.js @@ -122,8 +122,8 @@ var ensureAndroidBundle = function () { try { execFileSyncOrThrow('bash', [ensureScriptPath], { pipeOutput: true }); } catch (err) { - verboseLog('Failed to install android_bundle: ', err.stack); - throw new Error('Failed to install android_bundle: ' + err.message); + verboseLog('Failed to install android_bundle ', err.stack); + throw new Error('Failed to install android_bundle'); } }; From 0860b3626d6405c0ae440c50f53bd820eab7d50a Mon Sep 17 00:00:00 2001 From: Justin SB Date: Wed, 10 Sep 2014 16:03:42 -0700 Subject: [PATCH 3/5] Don't print a stack trace when android bundle fails to install --- tools/commands-cordova.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/commands-cordova.js b/tools/commands-cordova.js index 952eca99db..1352435ee5 100644 --- a/tools/commands-cordova.js +++ b/tools/commands-cordova.js @@ -123,7 +123,8 @@ var ensureAndroidBundle = function () { execFileSyncOrThrow('bash', [ensureScriptPath], { pipeOutput: true }); } catch (err) { verboseLog('Failed to install android_bundle ', err.stack); - throw new Error('Failed to install android_bundle'); + process.stderr.write("Failed to install android_bundle\n"); + throw new main.ExitWithCode(2); } }; From 2116f5bf53e4cbbdd1bdfac023a16625e7c892b9 Mon Sep 17 00:00:00 2001 From: Justin SB Date: Wed, 10 Sep 2014 16:09:21 -0700 Subject: [PATCH 4/5] Avoid running ensure_android twice on failure --- tools/commands-cordova.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/commands-cordova.js b/tools/commands-cordova.js index 1352435ee5..6573125d37 100644 --- a/tools/commands-cordova.js +++ b/tools/commands-cordova.js @@ -281,6 +281,9 @@ cordova.ensureCordovaProject = function (localPath, appName) { // XXX cache them there files.mkdir_p(localPluginsPath); } catch (err) { + if (err instanceof main.ExitWithCode) { + process.exit(err.code); + } process.stderr.write("Error creating Cordova project: " + err.message + "\n" + err.stack + "\n"); } From 14270c290e67b22f80ba5cd818c3a4e5eb56c4fb Mon Sep 17 00:00:00 2001 From: Justin SB Date: Wed, 10 Sep 2014 16:19:27 -0700 Subject: [PATCH 5/5] Be clear that we need a JDK, not just the JRE --- tools/cordova-scripts/ensure_android_bundle.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/cordova-scripts/ensure_android_bundle.sh b/tools/cordova-scripts/ensure_android_bundle.sh index 2f07597814..546ba5b64c 100755 --- a/tools/cordova-scripts/ensure_android_bundle.sh +++ b/tools/cordova-scripts/ensure_android_bundle.sh @@ -17,10 +17,10 @@ source $(dirname $0)/common_env.sh command -v java >/dev/null 2>&1 || { if [ ${UNAME} == "Linux" ] ; then - echo "Please install Java before running this command."; + echo "Please install a Java JDK before running this command."; echo "Directions can be found at: http://openjdk.java.net/install/" else - echo "The android platform needs Java to be installed on your system." + echo "The android platform needs a Java JDK to be installed on your system." java -version fi