You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bh...@apache.org on 2013/08/16 16:15:01 UTC
webworks commit: [CB-3798] Refactored all exec calls to use newly
created utility exec function to avoid path with spaces errors
Updated Branches:
refs/heads/master ed53b6c47 -> b6dfddf19
[CB-3798] Refactored all exec calls to use newly created utility exec function to avoid path with spaces errors
Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/b6dfddf1
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/b6dfddf1
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/b6dfddf1
Branch: refs/heads/master
Commit: b6dfddf1969e0a3b882714df0ec6a56bc818b50f
Parents: ed53b6c
Author: jkeshavarzi <jk...@blackberry.com>
Authored: Wed Aug 14 13:15:33 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri Aug 16 10:16:22 2013 -0400
----------------------------------------------------------------------
blackberry10/bin/lib/utils.js | 54 ++++-
.../project/cordova/lib/bar-builder.js | 8 +-
.../project/cordova/lib/debugtoken-helper.js | 39 +---
.../bin/templates/project/cordova/lib/run | 81 +++----
.../project/cordova/lib/signing-helper.js | 18 +-
.../project/cordova/lib/target-utils.js | 29 ++-
.../bin/templates/project/cordova/lib/utils.js | 218 -------------------
.../cordova/unit/spec/lib/signing-helper.js | 31 ++-
8 files changed, 138 insertions(+), 340 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b6dfddf1/blackberry10/bin/lib/utils.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/lib/utils.js b/blackberry10/bin/lib/utils.js
index 04fd6f3..627cbdd 100644
--- a/blackberry10/bin/lib/utils.js
+++ b/blackberry10/bin/lib/utils.js
@@ -16,6 +16,7 @@
var fs = require('fs'),
path = require('path'),
+ childProcess = require('child_process'),
wrench = require('wrench'),
localize = require("./localize"),
os = require('os'),
@@ -201,7 +202,58 @@ _self = {
},
inQuotes : function (property) {
- return "\"" + property + "\"";
+ //wrap in quotes if it's not already wrapped
+ if (property.indexOf("\"") === -1) {
+ return "\"" + property + "\"";
+ } else {
+ return property;
+ }
+ },
+
+ exec : function (command, args, options, callback) {
+ //Optional params handling [args, options]
+ if (typeof args === "Object" && !Array.isArray(args)) {
+ callback = options;
+ options = args;
+ args = [];
+ } else if (typeof args === "function"){
+ callback = args;
+ options = {};
+ args = [];
+ } else if (typeof options === "function"){
+ callback = options;
+ options = {};
+ }
+
+ //insert executable portion at begining of arg array
+ args.splice(0, 0, command);
+
+ var pkgrUtils = require("./packager-utils"),
+ customOptions = options._customOptions,
+ proc,
+ i;
+
+ for (i = 0; i < args.length; i++) {
+ if (args[i].indexOf(" ") !== -1) {
+ if (!_self.isWindows()) {
+ //remove any escaped spaces on non-Windows platforms and simply use quotes
+ args[i] = args[i].replace(/\\ /g, " ");
+ }
+
+ //put any args with spaces in quotes
+ args[i] = _self.inQuotes(args[i]);
+ }
+ };
+
+ //delete _customOptions from options object before sending to exec
+ delete options._customOptions;
+
+ proc = childProcess.exec(args.join(" "), options, callback);
+
+ if (!customOptions || !customOptions.silent) {
+ proc.stdout.on("data", pkgrUtils.handleProcessOutput);
+ proc.stderr.on("data", pkgrUtils.handleProcessOutput);
+ }
},
loadModule: function (path) {
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b6dfddf1/blackberry10/bin/templates/project/cordova/lib/bar-builder.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/bar-builder.js b/blackberry10/bin/templates/project/cordova/lib/bar-builder.js
index 0a955f9..992804c 100644
--- a/blackberry10/bin/templates/project/cordova/lib/bar-builder.js
+++ b/blackberry10/bin/templates/project/cordova/lib/bar-builder.js
@@ -53,8 +53,12 @@ function buildTarget(previous, baton) {
baton.pass(code);
} else {
if (target === "device" && session.isSigningRequired(config)) {
- signingHelper.execSigner(session, target, function (code) {
- baton.pass(code);
+ signingHelper.execSigner(session, target, function (error, stdout, stderr) {
+ if (error && error.code) {
+ baton.pass(error.code);
+ } else {
+ baton.pass();
+ }
});
} else {
baton.pass(code);
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b6dfddf1/blackberry10/bin/templates/project/cordova/lib/debugtoken-helper.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/debugtoken-helper.js b/blackberry10/bin/templates/project/cordova/lib/debugtoken-helper.js
index af42fce..0421b6e 100755
--- a/blackberry10/bin/templates/project/cordova/lib/debugtoken-helper.js
+++ b/blackberry10/bin/templates/project/cordova/lib/debugtoken-helper.js
@@ -100,27 +100,12 @@ function generateDeployTokenOptions(targetIp, targetPassword) {
}
function execNativeScript(script, options, callback) {
- var cp,
- script = path.join(process.env.CORDOVA_BBTOOLS, script);
+ var script = path.join(process.env.CORDOVA_BBTOOLS, script);
- if (pkgrUtils.isWindows()) {
- script += ".bat";
- }
-
- cp = childProcess.spawn(script, options, {
+ utils.exec(script, options, {
"cwd" : workingDir,
"env" : process.env
- });
-
- cp.stdout.on("data", pkgrUtils.handleProcessOutput);
-
- cp.stderr.on("data", pkgrUtils.handleProcessOutput);
-
- cp.on("exit", function (code) {
- if (callback && typeof callback === "function") {
- callback(code);
- }
- });
+ }, callback);
}
self.createToken = function (projectProperties, target, keystorepass, callback) {
@@ -176,8 +161,11 @@ self.deployToken = function (target, targetIp, targetPassword, callback) {
};
self.checkDebugToken = function (pin, callback) {
- var script = utils.inQuotes(path.join(process.env.CORDOVA_BBTOOLS, "blackberry-nativepackager")),
- nativePackager;
+ var script = path.normalize(path.join(process.env.CORDOVA_BBTOOLS, "blackberry-nativepackager")),
+ args = [
+ "-listManifest",
+ path.normalize(debugTokenDir)
+ ];
if (!callback || typeof callback !== "function") {
return;
@@ -188,18 +176,13 @@ self.checkDebugToken = function (pin, callback) {
return;
}
- if (pkgrUtils.isWindows()) {
- script += ".bat";
- }
-
- nativePackager = childProcess.exec(path.normalize(script + " -listManifest " + debugTokenDir), {
+ utils.exec(script, args, {
"cwd": workingDir,
- "env": process.env
+ "env": process.env,
+ _customOptions: { silent: true}
}, function (error, stdout, stderr) {
callback(isDebugTokenValid(pin, stdout));
});
-
- return;
};
module.exports = self;
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b6dfddf1/blackberry10/bin/templates/project/cordova/lib/run
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/run b/blackberry10/bin/templates/project/cordova/lib/run
index 3ec1b45..63b7d24 100755
--- a/blackberry10/bin/templates/project/cordova/lib/run
+++ b/blackberry10/bin/templates/project/cordova/lib/run
@@ -71,29 +71,13 @@ function generateOptions(uninstall) {
}
}
-function execNativeDeploy(optionsArray, callback) {
- var script = utils.inQuotes(path.join(process.env.CORDOVA_BBTOOLS, "blackberry-deploy")),
- nativeDeploy,
- options = optionsArray.join(" ");
+function execNativeDeploy(options, callback) {
+ var script = path.normalize(path.join(process.env.CORDOVA_BBTOOLS, "blackberry-deploy"));
- if (pkgrUtils.isWindows()) {
- script += ".bat";
- }
-
- nativeDeploy = childProcess.exec(path.normalize(script + " " + options), {
+ utils.exec(script, options, {
"cwd": workingdir,
"env": process.env
- });
-
- nativeDeploy.stdout.on("data", pkgrUtils.handleProcessOutput);
-
- nativeDeploy.stderr.on("data", pkgrUtils.handleProcessOutput);
-
- nativeDeploy.on("exit", function (code) {
- if (callback && typeof callback === "function") {
- callback(code);
- }
- });
+ }, callback);
}
function checkDeviceInfo(ip, deviceType, callback) {
@@ -190,16 +174,19 @@ function deploy() {
}
function uninstall() {
- var script = utils.inQuotes(path.join(process.env.CORDOVA_BBTOOLS, "blackberry-deploy")),
- nativeDeploy;
-
- if (pkgrUtils.isWindows()) {
- script += ".bat";
- }
-
- nativeDeploy = childProcess.exec(script + " -listInstalledApps -device " + ip + " -password " + password, {
+ var script = path.join(process.env.CORDOVA_BBTOOLS, "blackberry-deploy"),
+ args = [
+ "-listInstalledApps",
+ "-device",
+ ip,
+ "-password",
+ password
+ ];
+
+ utils.exec(script, args, {
"cwd": workingdir,
- "env": process.env
+ "env": process.env,
+ _customOptions: { silent: true}
}, function (error, stdout, stderr) {
var parser = new xml2js.Parser();
fs.readFile(path.join(__dirname + "/../../www/", "config.xml"), function (err, data) {
@@ -244,8 +231,8 @@ function createDebugToken(previous, baton) {
baton.take();
if (needCreateDebugToken) {
- debugTokenHelper.createToken(targets, "all", keystorepass, function (code) {
- if (code === 0) {
+ debugTokenHelper.createToken(targets, "all", keystorepass, function (error, stdout, stderr) {
+ if (!error) {
// Deploy the debug token if created
needDeployDebugToken = true;
}
@@ -276,32 +263,22 @@ function handleBuildOutput(data) {
}
function build(previous, baton) {
- var nativeDeploy,
- execName = "./build";
+ var execName = utils.isWindows() ? "build" : "./build",
+ callback = function (code) {
+ // If error happened during building the bar, exit
+ if (code === 2) {
+ process.exit(2);
+ }
- baton.take();
+ baton.pass();
+ };
- if (pkgrUtils.isWindows()) {
- execName = "build";
- }
+ baton.take();
- nativeDeploy = childProcess.exec(execName, {
+ utils.exec(execName, [], {
"cwd": path.normalize(__dirname + "/.."),
"env": process.env
- });
-
- nativeDeploy.stdout.on("data", handleBuildOutput);
-
- nativeDeploy.stderr.on("data", handleBuildOutput);
-
- nativeDeploy.on("exit", function (code) {
- // If error happened during building the bar, exit
- if (code === 2) {
- process.exit(2);
- }
-
- baton.pass();
- });
+ }, callback);
}
function postBuild() {
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b6dfddf1/blackberry10/bin/templates/project/cordova/lib/signing-helper.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/signing-helper.js b/blackberry10/bin/templates/project/cordova/lib/signing-helper.js
index 2fce263..cb7d60d 100644
--- a/blackberry10/bin/templates/project/cordova/lib/signing-helper.js
+++ b/blackberry10/bin/templates/project/cordova/lib/signing-helper.js
@@ -67,10 +67,6 @@ function execSigner(session, target, callback) {
params = session.getParams("blackberry-signer"),
args = [];
- if (pkgrUtils.isWindows()) {
- script += ".bat";
- }
-
args.push("-keystore");
args.push(session.keystore);
args.push("-storepass");
@@ -88,19 +84,9 @@ function execSigner(session, target, callback) {
args.push(path.resolve(util.format(session.barPath, target)));
- signer = childProcess.spawn(script, args, {
+ utils.exec(script, args, {
"env": process.env
- });
-
- signer.stdout.on("data", pkgrUtils.handleProcessOutput);
-
- signer.stderr.on("data", pkgrUtils.handleProcessOutput);
-
- signer.on("exit", function (code) {
- if (callback && typeof callback === "function") {
- callback(code);
- }
- });
+ }, callback);
}
_self = {
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b6dfddf1/blackberry10/bin/templates/project/cordova/lib/target-utils.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/target-utils.js b/blackberry10/bin/templates/project/cordova/lib/target-utils.js
index cd6829f..af95296 100644
--- a/blackberry10/bin/templates/project/cordova/lib/target-utils.js
+++ b/blackberry10/bin/templates/project/cordova/lib/target-utils.js
@@ -17,7 +17,6 @@
var _self,
os = require("os"),
fs = require('fs'),
- exec = require('child_process').exec,
path = require('path'),
bb10_utils = require('./utils'),
blackberryProperties = bb10_utils.getProperties();
@@ -66,11 +65,21 @@ _self = {
},
getDeviceInfo: function (ip, password, callback) {
- var cmd = path.join(process.env.CORDOVA_BBTOOLS, 'blackberry-deploy') + ' -listDeviceInfo ' + ip;
+ var cmd = path.join(process.env.CORDOVA_BBTOOLS, 'blackberry-deploy'),
+ args = [
+ '-listDeviceInfo',
+ ip
+ ],
+ options = {
+ _customOptions: { silent: true }
+ };
+
if (password) {
- cmd += ' -password ' + password;
+ args.push('-password');
+ args.push(password);
}
- exec(cmd, function (error, stdout, stderr) {
+
+ bb10_utils.exec(cmd, args, options, function (error, stdout, stderr) {
var result = {},
name = /modelname::(.*?)(\r?)\n/.exec(stdout),
pin = /devicepin::0x(.*?)(\r?)\n/.exec(stdout);
@@ -205,8 +214,16 @@ _self = {
},
checkConnection: function (ip, type, callback) {
- var script = path.join(process.env.CORDOVA_BBTOOLS, 'blackberry-deploy');
- exec(script + ' -test ' + ip, function (error, stdout, stderr) {
+ var script = path.join(process.env.CORDOVA_BBTOOLS, 'blackberry-deploy'),
+ args = [
+ '-test',
+ ip
+ ],
+ options = {
+ _customOptions: { silent: true }
+ };
+
+ bb10_utils.exec(script, args, options, function (error, stdout, stderr) {
// error code 3 corresponds to a connected device, null or "Error: null" in stderr corresponds to connected simulator
callback((type === 'simulator' && (error === null || stderr.length === 0 || stderr.indexOf('Error: null') >= 0 || stderr.indexOf('Error: Authentication failed') >= 0)) || (type === 'device' && error.code === 3));
});
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b6dfddf1/blackberry10/bin/templates/project/cordova/lib/utils.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/utils.js b/blackberry10/bin/templates/project/cordova/lib/utils.js
deleted file mode 100644
index 8a05ddc..0000000
--- a/blackberry10/bin/templates/project/cordova/lib/utils.js
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Copyright 2012 Research In Motion Limited.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var fs = require('fs'),
- path = require('path'),
- wrench = require('wrench'),
- localize = require("./localize"),
- os = require('os'),
- DEFAULT_BAR_NAME = "bb10app",
- PROPERTY_FILE_NAME = 'blackberry10.json',
- CORDOVA_DIR = '.cordova',
- DEFAULT_PROPERTY_FILE = {
- targets: {
- }
- },
- _self;
-
-function swapBytes(buffer) {
- var l = buffer.length,
- i,
- a;
-
- if (l % 2 === 0x01) {
- throw localize.translate("EXCEPTION_BUFFER_ERROR");
- }
-
- for (i = 0; i < l; i += 2) {
- a = buffer[i];
- buffer[i] = buffer[i + 1];
- buffer[i + 1] = a;
- }
-
- return buffer;
-}
-
-_self = {
- writeFile: function (fileLocation, fileName, fileData) {
- //If directory does not exist, create it.
- if (!fs.existsSync(fileLocation)) {
- wrench.mkdirSyncRecursive(fileLocation, "0755");
- }
-
- fs.writeFile(path.join(fileLocation, fileName), fileData, function (err) {
- if (err) throw err;
- });
- },
-
- copyFile: function (srcFile, destDir, baseDir) {
- var filename = path.basename(srcFile),
- fileBuffer = fs.readFileSync(srcFile),
- fileLocation;
-
- //if a base directory was provided, determine
- //folder structure from the relative path of the base folder
- if (baseDir && srcFile.indexOf(baseDir) === 0) {
- fileLocation = srcFile.replace(baseDir, destDir);
- wrench.mkdirSyncRecursive(path.dirname(fileLocation), "0755");
- fs.writeFileSync(fileLocation, fileBuffer);
- } else {
- if (!fs.existsSync(destDir)) {
- wrench.mkdirSyncRecursive(destDir, "0755");
- }
-
- fs.writeFileSync(path.join(destDir, filename), fileBuffer);
- }
- },
-
- listFiles: function (directory, filter) {
- var files = wrench.readdirSyncRecursive(directory),
- filteredFiles = [];
-
- files.forEach(function (file) {
- //On mac wrench.readdirSyncRecursive does not return absolute paths, so resolve one.
- file = path.resolve(directory, file);
-
- if (filter(file)) {
- filteredFiles.push(file);
- }
- });
-
- return filteredFiles;
- },
-
- isWindows: function () {
- return os.type().toLowerCase().indexOf("windows") >= 0;
- },
-
- isArray: function (obj) {
- return obj.constructor.toString().indexOf("Array") !== -1;
- },
-
- isEmpty : function (obj) {
- for (var prop in obj) {
- if (obj.hasOwnProperty(prop))
- return false;
- }
- return true;
- },
-
- toBoolean: function (myString, defaultVal) {
- // if defaultVal is not passed, default value is undefined
- return myString === "true" ? true : myString === "false" ? false : defaultVal;
- },
-
- parseUri : function (str) {
- var i, uri = {},
- key = [ "source", "scheme", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor" ],
- matcher = /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(str);
-
- for (i = key.length - 1; i >= 0; i--) {
- uri[key[i]] = matcher[i] || "";
- }
-
- return uri;
- },
-
- // uri - output from parseUri
- isAbsoluteURI : function (uri) {
- if (uri && uri.source) {
- return uri.relative !== uri.source;
- }
-
- return false;
- },
-
- isLocalURI : function (uri) {
- return uri && uri.scheme && uri.scheme.toLowerCase() === "local";
- },
-
- // Convert node.js Buffer data (encoded) to String
- bufferToString : function (data) {
- var s = "";
- if (Buffer.isBuffer(data)) {
- if (data.length >= 2 && data[0] === 0xFF && data[1] === 0xFE) {
- s = data.toString("ucs2", 2);
- } else if (data.length >= 2 && data[0] === 0xFE && data[1] === 0xFF) {
- swapBytes(data);
- s = data.toString("ucs2", 2);
- } else if (data.length >= 3 && data[0] === 0xEF && data[1] === 0xBB && data[2] === 0xBF) {
- s = data.toString("utf8", 3);
- } else {
- s = data.toString("ascii");
- }
- }
-
- return s;
- },
-
- // Wrap object property in an Array if the property is defined and it is not an Array
- wrapPropertyInArray : function (obj, property) {
- if (obj && obj[property] && !(obj[property] instanceof Array)) {
- obj[property] = [ obj[property] ];
- }
- },
-
- loadModule: function (path) {
- return require(path);
- },
-
- findHomePath : function () {
- return process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
- },
-
- getCordovaDir: function () {
- var cordovaPath = path.join(_self.findHomePath(), CORDOVA_DIR);
-
- if (!fs.existsSync(cordovaPath)) {
- fs.mkdirSync(cordovaPath);
- }
-
- return cordovaPath;
- },
-
- getPropertiesFilePath: function () {
- var propertiesFile = path.join(_self.getCordovaDir(), PROPERTY_FILE_NAME);
-
- if (!fs.existsSync(propertiesFile)) {
- _self.writeToPropertiesFile(DEFAULT_PROPERTY_FILE);
- }
-
- return propertiesFile;
- },
-
- getPropertiesFileName: function () {
- return PROPERTY_FILE_NAME;
- },
-
- getProperties: function () {
- return require(_self.getPropertiesFilePath());
- },
-
- writeToPropertiesFile: function (data) {
- var contents = JSON.stringify(data, null, 4) + "\n",
- propertiesFile = path.join(_self.getCordovaDir(), PROPERTY_FILE_NAME);
-
- fs.writeFileSync(propertiesFile, contents, 'utf-8');
- },
-
- genBarName: function() {
- return DEFAULT_BAR_NAME;
- }
-
-};
-
-module.exports = _self;
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b6dfddf1/blackberry10/bin/test/cordova/unit/spec/lib/signing-helper.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/cordova/unit/spec/lib/signing-helper.js b/blackberry10/bin/test/cordova/unit/spec/lib/signing-helper.js
index 8aa37fd..d2a4ab3 100644
--- a/blackberry10/bin/test/cordova/unit/spec/lib/signing-helper.js
+++ b/blackberry10/bin/test/cordova/unit/spec/lib/signing-helper.js
@@ -357,7 +357,7 @@ describe("signing-helper", function () {
session.storepass = "123";
session.barPath = path.normalize("c:/%s/" + "Demo.bar");
- spyOn(childProcess, "spawn").andReturn({
+ spyOn(childProcess, "exec").andReturn({
stdout: {
on: stdoutOn
},
@@ -374,39 +374,36 @@ describe("signing-helper", function () {
it("exec blackberry-signer without extra params", function () {
var callback = jasmine.createSpy("callback"),
- cmd = "blackberry-signer" + (pkgrUtils.isWindows() ? ".bat" : "");
+ cmd = "blackberry-signer";
session.getParams = jasmine.createSpy("session getParams").andReturn(null);
signingHelper.execSigner(session, "device", callback);
- expect(childProcess.spawn).toHaveBeenCalledWith(cmd, ["-keystore", session.keystore, "-storepass", session.storepass, path.resolve("c:/device/Demo.bar")], jasmine.any(Object));
+ expect(childProcess.exec).toHaveBeenCalledWith([cmd, "-keystore", session.keystore, "-storepass", session.storepass, path.resolve("c:/device/Demo.bar")].join(" "), jasmine.any(Object), callback);
expect(stdoutOn).toHaveBeenCalledWith("data", pkgrUtils.handleProcessOutput);
expect(stderrOn).toHaveBeenCalledWith("data", pkgrUtils.handleProcessOutput);
- expect(callback).toHaveBeenCalledWith(0);
});
it("exec blackberry-signer with extra params", function () {
var callback = jasmine.createSpy("callback"),
- cmd = "blackberry-signer" + (pkgrUtils.isWindows() ? ".bat" : "");
+ cmd = "blackberry-signer";
session.getParams = jasmine.createSpy("session getParams").andReturn({
"-proxyhost": "abc.com",
"-proxyport": "80"
});
signingHelper.execSigner(session, "device", callback);
- expect(childProcess.spawn.mostRecentCall.args[0]).toBe(cmd);
- expect(childProcess.spawn.mostRecentCall.args[1]).toContain("-keystore");
- expect(childProcess.spawn.mostRecentCall.args[1]).toContain(session.keystore);
- expect(childProcess.spawn.mostRecentCall.args[1]).toContain("-storepass");
- expect(childProcess.spawn.mostRecentCall.args[1]).toContain(session.storepass);
- expect(childProcess.spawn.mostRecentCall.args[1]).toContain("-proxyport");
- expect(childProcess.spawn.mostRecentCall.args[1]).toContain("80");
- expect(childProcess.spawn.mostRecentCall.args[1]).toContain("-proxyhost");
- expect(childProcess.spawn.mostRecentCall.args[1]).toContain("abc.com");
- expect(childProcess.spawn.mostRecentCall.args[1]).toContain(path.resolve("c:/device/Demo.bar"));
- expect(childProcess.spawn.mostRecentCall.args[1].length).toBe(9);
+ expect(childProcess.exec.mostRecentCall.args[0]).toContain(cmd);
+ expect(childProcess.exec.mostRecentCall.args[0]).toContain("-keystore");
+ expect(childProcess.exec.mostRecentCall.args[0]).toContain(session.keystore);
+ expect(childProcess.exec.mostRecentCall.args[0]).toContain("-storepass");
+ expect(childProcess.exec.mostRecentCall.args[0]).toContain(session.storepass);
+ expect(childProcess.exec.mostRecentCall.args[0]).toContain("-proxyport");
+ expect(childProcess.exec.mostRecentCall.args[0]).toContain("80");
+ expect(childProcess.exec.mostRecentCall.args[0]).toContain("-proxyhost");
+ expect(childProcess.exec.mostRecentCall.args[0]).toContain("abc.com");
+ expect(childProcess.exec.mostRecentCall.args[0]).toContain(path.resolve("c:/device/Demo.bar"));
expect(stdoutOn).toHaveBeenCalledWith("data", pkgrUtils.handleProcessOutput);
expect(stderrOn).toHaveBeenCalledWith("data", pkgrUtils.handleProcessOutput);
- expect(callback).toHaveBeenCalledWith(0);
});
});
});