Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
CB-4531 bin/check_reqs scripts exit with code 2 on error
- Return ERROR_VALUE/NOTIMPLEMENTED_VALUE
- Restore number path for symmetry with install-emulator, install-device, build
- Refactor exit_handler into utils

Reviewed by James Keshavarzi <jkeshavarzi@blackberry.com>
Tested by Jenny Gee <jgee@blackberry.com>
  • Loading branch information
jsoref authored and bryanhiggins committed Nov 5, 2013
1 parent 0c13f4a commit 4dcdb991179c419765f5af5ec0c911fc29ff5fb4
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 86 deletions.
@@ -24,5 +24,5 @@ if not exist INITCALL (
)

call %INITCALL%
if ERRORLEVEL 1 exit /B 1
if ERRORLEVEL 1 exit /B %ERRORLEVEL%

@@ -18,6 +18,7 @@
*/

var MIN_NODE_VER = "0.9.9",
ERROR_VALUE = 2,
signingUtils = require('./lib/signing-utils');

function isNodeNewerThanMin () {
@@ -29,7 +30,7 @@ function isNodeNewerThanMin () {

if (!isNodeNewerThanMin()) {
console.log("Node version '" + process.versions.node + "' is not new enough. Please upgrade to " + MIN_NODE_VER + " or newer. Aborting.");
process.exit(2);
process.exit(ERROR_VALUE);
}

if (!signingUtils.getKeyStorePath()) {
@@ -40,7 +40,7 @@ if [ -e "$NPM_PACKAGE_JSON" ]; then

if ! [ $? -eq 0 ]; then
echo "NPM install failed. Aborting."
exit 1
exit $?
fi
fi

@@ -20,7 +20,7 @@ goto comment
set BIN_DIR=%~dp0

call "%BIN_DIR%init"
if ERRORLEVEL 1 exit /B 1
if ERRORLEVEL 1 exit /B %ERRORLEVEL%

if exist "%BIN_DIR%..\package.json" (
pushd %BIN_DIR%..
@@ -30,3 +30,4 @@ if exist "%BIN_DIR%..\package.json" (
)

"%CORDOVA_NODE%\node" "%BIN_DIR%create.js" %*
if ERRORLEVEL 1 exit /B %ERRORLEVEL%
@@ -42,6 +42,7 @@ var build,
BIN_DIR = path.join(__dirname),
BUILD_DIR = path.join(__dirname, "build"),
CORDOVA_JS_SRC = path.join(__dirname, "..", "javascript", "cordova.blackberry10.js"),
ERROR_VALUE = 2,
update_dir = path.join(project_path, "lib", "cordova." + version),
native_dir = path.join(project_path, "native"),
js_path = "javascript",
@@ -68,7 +69,7 @@ function validateProjectPath() {
if (!process.argv[2]) {
console.log("You must give a project PATH");
help();
process.exit(2);
process.exit(ERROR_VALUE);
return "";
} else {
return path.resolve(process.argv[2]);
@@ -79,7 +80,7 @@ function validate() {
if (fs.existsSync(project_path)) {
console.log("The project path must be an empty directory");
help();
process.exit(2);
process.exit(ERROR_VALUE);
}
if (!validPackageName(app_id)) {
console.log("[warning] App ID must be sequence of alpha-numeric (optionally separated by '.') characters, no longer than 50 characters.\n" +
@@ -193,6 +194,6 @@ if ( process.argv[2] === "-h" || process.argv[2] === "--help" ) {
} catch (ex) {
console.log("Project creation failed!");
console.error(os.EOL + ex);
process.exit(2);
process.exit(ERROR_VALUE);
}
}
@@ -20,6 +20,8 @@ var path = require('path'),
utils = require('./utils'),
commander = require('commander'),
properties = utils.getProperties(),
ERROR_VALUE = 2,
NOTIMPLEMENTED_VALUE = 1,
command,
name,
ip,
@@ -36,7 +38,7 @@ function isValidIp(ip) {
if (typeof ip !== 'string') {
console.log("IP is required");
console.log(commander.helpInformation());
process.exit(2);
process.exit(ERROR_VALUE);
} else {
ipArray = ip.split('.');
if (ipArray.length !== 4) {
@@ -58,7 +60,7 @@ function isValidType(type) {
if (typeof type !== 'string') {
console.log("target type is required");
console.log(commander.helpInformation());
process.exit(2);
process.exit(ERROR_VALUE);
}
else if (!(type === 'device' || type === 'simulator')) {
result = false;
@@ -97,7 +99,7 @@ commander
if (commander.args.length === 1) {
console.log("Target details not specified");
console.log(commander.helpInformation());
process.exit(2);
process.exit(ERROR_VALUE);
}
name = commander.args[0];
ip = commander.args[1];
@@ -111,17 +113,17 @@ commander
if (!isValidIp(ip)) {
console.log("Invalid IP: " + ip);
console.log(commander.helpInformation());
process.exit(2);
process.exit(ERROR_VALUE);
}
if (!isValidType(type)) {
console.log("Invalid target type: " + type);
console.log(commander.helpInformation());
process.exit(2);
process.exit(ERROR_VALUE);
}
if (!isValidPin(pin)) {
console.log("Invalid PIN: " + pin);
console.log(commander.helpInformation());
process.exit(2);
process.exit(ERROR_VALUE);
}
if (properties.targets.hasOwnProperty(name)) {
console.log("Overwriting target: " + name);
@@ -136,13 +138,13 @@ commander
if (commander.args.length === 1) {
console.log('No target specified');
console.log(commander.helpInformation());
process.exit(2);
process.exit(ERROR_VALUE);
}
name = commander.args[0];
if (!properties.targets.hasOwnProperty(name)) {
console.log("Target: '" + name + "' not found");
console.log(commander.helpInformation());
process.exit(2);
process.exit(ERROR_VALUE);
}
if (name === properties.defaultTarget) {
console.log("Deleting default target, please set a new default target");
@@ -165,7 +167,7 @@ commander
} else {
console.log("Target '" + name + "' not found");
console.log(commander.helpInformation());
process.exit(2);
process.exit(ERROR_VALUE);
}
});

@@ -174,7 +176,7 @@ commander
.action(function () {
console.log('Unrecognized command');
console.log(commander.helpInformation());
process.exit(2);
process.exit(NOTIMPLEMENTED_VALUE);
});


@@ -15,6 +15,7 @@
*/

var fs = require('fs'),
async = require('async'),
path = require('path'),
childProcess = require('child_process'),
wrench = require('wrench'),
@@ -24,6 +25,7 @@ var fs = require('fs'),
DEFAULT_BAR_NAME = "bb10app",
PROPERTY_FILE_NAME = 'blackberry10.json',
CORDOVA_DIR = '.cordova',
ERROR_VALUE = 2,
DEFAULT_PROPERTY_FILE = {
targets: {
}
@@ -346,6 +348,27 @@ _self = {
}
});
return to;
},

series: function (steps) {
async.series(steps, this.exit_handler);
},

waterfall: function (steps) {
async.waterfall(steps, this.exit_handler);
},

exit_handler: function (err) {
if (err) {
if (typeof err === "string") {
console.error(err);
} else {
console.error("An error has occurred");
}
process.exit(ERROR_VALUE);
} else {
process.exit(0);
}
}

};
@@ -32,6 +32,7 @@ var path = require("path"),
childProcess = require("child_process"),
pkgrUtils = require("./packager-utils"),
session = require("./session"),
ERROR_VALUE = 2,
commandStr;

function copyArgIfExists(arg) {
@@ -58,10 +59,10 @@ try {
if (command.debug && command.release) {
console.error("Invalid build command: cannot specify both debug and release parameters.");
console.log(command.helpInformation());
process.exit(2);
process.exit(ERROR_VALUE);
}

async.series(
utils.series(
[
function clean (done) {
var cmd = utils.isWindows() ? "clean" : "./clean",
@@ -112,24 +113,10 @@ try {

require("./packager").start(done);
}
],
function (err, results) {
if (err) {
if (typeof err === "string") {
console.error(os.EOL + err);
process.exit(2);
} else if (typeof err === "number") {
process.exit(err);
} else {
process.exit(2);
}
} else {
process.exit(0);
}
}
]
);
} catch (e) {
console.error(os.EOL + e);
process.exit(2);
process.exit(ERROR_VALUE);
}

@@ -20,8 +20,7 @@ var path = require("path"),
utils = require("./utils"),
options = require('commander'),
runUtils = require("./run-utils"),
logger = require("./logger"),
async = require("async");
logger = require("./logger");

options
.usage('[--target=id]')
@@ -47,23 +46,11 @@ process.argv.forEach(function (argument, index, args) {
options.parse(process.argv);

options.device = true;
async.waterfall(
utils.waterfall(
[
runUtils.getValidatedTarget.bind(this, options),
runUtils.checkBuild,
runUtils.uninstall.bind(this, options),
runUtils.deployToTarget.bind(this, options)
],
function (err) {
if (err) {
if (typeof err === "string") {
logger.error(err);
process.exit(1);
} else if (typeof err === "number") {
process.exit(err);
}
} else {
process.exit(0);
}
}
]
);
@@ -20,8 +20,7 @@ var path = require("path"),
utils = require("./utils"),
options = require('commander'),
runUtils = require("./run-utils"),
logger = require("./logger"),
async = require("async");
logger = require("./logger");

options
.usage('[--target=id]')
@@ -47,23 +46,11 @@ process.argv.forEach(function (argument, index, args) {
options.parse(process.argv);

options.emulator = true;
async.waterfall(
utils.waterfall(
[
runUtils.getValidatedTarget.bind(this, options),
runUtils.checkBuild,
runUtils.uninstall.bind(this, options),
runUtils.deployToTarget.bind(this, options)
],
function (err) {
if (err) {
if (typeof err === "string") {
logger.error(err);
process.exit(1);
} else if (typeof err === "number") {
process.exit(err);
}
} else {
process.exit(0);
}
}
]
);
@@ -18,6 +18,7 @@
under the License.
COMMENT
set -e
NOTIMPLEMENTED_VALUE=1

echo 'BlackBerry10: logging not supported at this time.'
exit 1
exit $NOTIMPLEMENTED_VALUE
@@ -21,8 +21,7 @@ var path = require("path"),
utils = require("./utils"),
options = require('commander'),
runUtils = require("./run-utils"),
async = require("async"),
ERROR_CODE = 2;
async = require("async");

function install(deployTarget, done) {
var buildCmd = utils.isWindows() ? "build" : "./build",
@@ -69,19 +68,9 @@ process.argv.forEach(function (argument, index, args) {

options.parse(process.argv);

async.waterfall(
utils.waterfall(
[
runUtils.getValidatedTarget.bind(this, options),
install
],
function (err) {
if (err) {
if (typeof err === "string") {
console.error(os.EOL + err);
}
process.exit(ERROR_CODE);
} else {
process.exit(0);
}
}
]
);

0 comments on commit 4dcdb99

Please sign in to comment.