Skip to content

Commit

Permalink
Merge branch 'better-install' into cordova-hcp
Browse files Browse the repository at this point in the history
  • Loading branch information
Sashko Stubailo committed Aug 19, 2014
2 parents ff1a6c0 + e59bf43 commit 22b7ce7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions scripts/cordova.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ export PATH=${ANT_HOME}/bin:${PATH}
export PATH=${DEV_BUNDLE}/bin:${PATH}
export NODE_PATH="${DEV_BUNDLE}/lib/node_modules"

export HOME="${ANDROID_BUNDLE}"

exec ${DEV_BUNDLE}/lib/node_modules/cordova/bin/cordova "$@"

15 changes: 15 additions & 0 deletions scripts/ensure_android_bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ if [ "$UNAME" != "Linux" -a "$UNAME" != "Darwin" ] ; then
exit 1
fi

command -v java >/dev/null 2>&1 || {
if [ UNAME == "Linux" ] ; then
echo "Please install Java 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."
java -version
fi

exit 1;
}


# Find the script dir, following one level of symlink. Note that symlink
# can be relative or absolute. Too bad 'readlink -f' is not portable.
ORIG_DIR=$(pwd)
Expand Down Expand Up @@ -76,6 +89,8 @@ export PATH=${ANDROID_BUNDLE}/android-sdk/tools:${ANDROID_BUNDLE}/android-sdk/pl
export ANT_HOME=${ANDROID_BUNDLE}/apache-ant-1.9.4
export PATH=${ANT_HOME}/bin:${PATH}

export HOME=${ANDROID_BUNDLE}

# create avd if necessary
if [[ ! $(${ANDROID_BUNDLE}/android-sdk/tools/android list avd | grep Name) ]] ; then
echo "
Expand Down
9 changes: 7 additions & 2 deletions tools/commands-cordova.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ var execFileAsyncOrThrow = function (file, args, opts) {
var execFileSyncOrThrow = function (file, args, opts) {
var execFileSync = require('./utils.js').execFileSync;
if (_.contains([localCordova, localAdb], file) &&
_.contains(project.getCordovaPlatforms(), 'android'))
_.contains(project.getCordovaPlatforms(), 'android')) {
ensureAndroidBundle();
}

var process = execFileSync(file, args, opts);
if (! process.success)
Expand All @@ -60,7 +61,11 @@ var ensureAndroidBundle = function () {
var ensureScriptPath = path.join(files.getCurrentToolsDir(),
'scripts', 'ensure_android_bundle.sh');

execFileSyncOrThrow('sh', [ensureScriptPath], { pipeOutput: true });
try {
execFileSyncOrThrow('bash', [ensureScriptPath], { pipeOutput: true });
} catch (err) {
process.exit();
}
};

var getLoadedPackages = _.once(function () {
Expand Down

0 comments on commit 22b7ce7

Please sign in to comment.