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 2014/04/13 03:08:35 UTC
[53/53] [abbrv] webworks commit: CB-6440 Move utils.js from bin to
template
CB-6440 Move utils.js from bin to template
Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/942b81e7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/942b81e7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/942b81e7
Branch: refs/heads/master
Commit: 942b81e70e978f225e187c566dfb9b7885c15973
Parents: 84f8308
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Sat Apr 12 20:53:45 2014 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Sat Apr 12 21:04:26 2014 -0400
----------------------------------------------------------------------
blackberry10/.gitignore | 1 -
blackberry10/.jshintignore | 2 -
blackberry10/bin/lib/create.js | 1 -
blackberry10/bin/lib/localize.js | 26 --
blackberry10/bin/lib/update.js | 1 -
blackberry10/bin/lib/utils.js | 386 -------------------
.../bin/templates/project/cordova/lib/utils.js | 385 ++++++++++++++++++
.../bin/test/cordova/integration/create.js | 2 +-
.../bin/test/cordova/integration/target.js | 2 +-
blackberry10/scripts/test.js | 1 -
10 files changed, 387 insertions(+), 420 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/942b81e7/blackberry10/.gitignore
----------------------------------------------------------------------
diff --git a/blackberry10/.gitignore b/blackberry10/.gitignore
index 152fd68..bd024b8 100644
--- a/blackberry10/.gitignore
+++ b/blackberry10/.gitignore
@@ -17,6 +17,5 @@ deliverables/
build/
dist/
bin/templates/project/lib
-bin/templates/project/cordova/lib/utils.js
example/
.tmp
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/942b81e7/blackberry10/.jshintignore
----------------------------------------------------------------------
diff --git a/blackberry10/.jshintignore b/blackberry10/.jshintignore
index 0c74354..5a8fb35 100644
--- a/blackberry10/.jshintignore
+++ b/blackberry10/.jshintignore
@@ -3,5 +3,3 @@ bin/test/cordova/unit/params-bad.json
bin/templates/project/cordova/lib/xml-helpers.js
bin/templates/project/cordova/third_party/*
bin/templates/project/lib/*
-bin/templates/project/cordova/lib/utils.js
-bin/templates/project/cordova/lib/signing-utils.js
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/942b81e7/blackberry10/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/lib/create.js b/blackberry10/bin/lib/create.js
index d4623b1..01bad98 100644
--- a/blackberry10/bin/lib/create.js
+++ b/blackberry10/bin/lib/create.js
@@ -125,7 +125,6 @@ function copyFilesToProject() {
shell.cp(path.join(BIN_DIR, "target"), path.join(project_path, "cordova"));
shell.cp(path.join(BIN_DIR, "target.bat"), path.join(project_path, "cordova"));
shell.cp(path.join(BIN_DIR, "lib", "target.js"), path.join(project_path, "cordova", "lib"));
- shell.cp(path.join(BIN_DIR, "lib", "utils.js"), path.join(project_path, "cordova", "lib"));
// copy repo level init script to project
shell.cp(path.join(BIN_DIR, "whereis.cmd"), path.join(project_path, "cordova"));
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/942b81e7/blackberry10/bin/lib/localize.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/lib/localize.js b/blackberry10/bin/lib/localize.js
deleted file mode 100644
index 66bddfa..0000000
--- a/blackberry10/bin/lib/localize.js
+++ /dev/null
@@ -1,26 +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 Localize = require("localize"),
- loc = new Localize({
- "SOME_WARNING": {
- "en": "You have disabled all web security in this WebWorks application"
- }
- }, "", ""); // TODO maybe a bug in localize, must set default locale to "" in order get it to work
-
-loc.setLocale("en");
-
-module.exports = loc;
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/942b81e7/blackberry10/bin/lib/update.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/lib/update.js b/blackberry10/bin/lib/update.js
old mode 100755
new mode 100644
index 9e66bd1..a089691
--- a/blackberry10/bin/lib/update.js
+++ b/blackberry10/bin/lib/update.js
@@ -56,7 +56,6 @@ function updateTargetTool(projectpath) {
shell.cp('-f', path.join(ROOT, 'bin', 'target'), path.join(projectpath, 'cordova'));
shell.cp('-f', path.join(ROOT, 'bin', 'target.bat'), path.join(projectpath, 'cordova'));
shell.cp('-f', path.join(ROOT, 'bin', 'lib', 'target.js'), path.join(projectpath, 'cordova', 'lib'));
- shell.cp('-f', path.join(ROOT, 'bin', 'lib', 'utils.js'), path.join(projectpath, 'cordova', 'lib'));
}
function updateInitTool(projectpath) {
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/942b81e7/blackberry10/bin/lib/utils.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/lib/utils.js b/blackberry10/bin/lib/utils.js
deleted file mode 100644
index b05e3d7..0000000
--- a/blackberry10/bin/lib/utils.js
+++ /dev/null
@@ -1,386 +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.
- */
-
-/* globals Buffer */
-
-var fs = require('fs'),
- exit = require('exit'),
- async = require('async'),
- path = require('path'),
- childProcess = require('child_process'),
- wrench = require('wrench'),
- localize = require("./localize"),
- os = require('os'),
- promptLib = require("prompt"),
- DEFAULT_BAR_NAME = "bb10app",
- PROPERTY_FILE_NAME = 'blackberry10.json',
- CORDOVA_DIR = '.cordova',
- ERROR_VALUE = 2,
- 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;
- },
-
- readdirSyncRecursive: function (baseDir) {
- var files = [],
- curFiles = [],
- nextDirs,
- isDir = function (f) {
- return fs.statSync(f).isDirectory();
- },
- isFile = function (f) {
- return !isDir(f);
- },
- prependBaseDir = function (fname) {
- return path.join(baseDir, fname);
- };
-
- try {
- curFiles = fs.readdirSync(baseDir);
-
- if (curFiles && curFiles.length > 0) {
- curFiles = curFiles.map(prependBaseDir);
- nextDirs = curFiles.filter(isDir);
- curFiles = curFiles.filter(isFile);
-
- files = files.concat(curFiles);
-
- while (nextDirs.length) {
- files = files.concat(_self.readdirSyncRecursive(nextDirs.shift()));
- }
- }
- } catch (e) {
- }
-
- return files;
- },
-
- isWindows: function () {
- return os.type().toLowerCase().indexOf("windows") >= 0;
- },
-
- isOSX: function () {
- return os.type().toLowerCase().indexOf("darwin") >= 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] ];
- }
- },
-
- inQuotes : function (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 beginning 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] && 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;
- //Use the process env by default
- options.env = options.env || process.env;
-
- 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) {
- return require(path);
- },
-
- findHomePath : function () {
- return process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'];
- },
-
- 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 () {
- var props = require(_self.getPropertiesFilePath());
- if (!props.targets) {
- props.targets = {};
- }
- return props;
- },
-
- 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;
- },
-
- clone: function (original) {
- var clone = {},
- prop;
- if (typeof original !== "object") {
- clone = original;
- } else if (Array.isArray(original)) {
- clone = original.slice();
- } else {
- /* jshint ignore:start */
- for (prop in original) {
- clone[prop] = original[prop];
- }
- /* jshint ignore:end */
- }
-
- return clone;
- },
- prompt: function (options, done) {
- var promptSchema = {
- properties: {
- "property": options
- }
- };
- promptLib.start();
- promptLib.colors = false;
- promptLib.message = "";
- promptLib.delimiter = "";
- promptLib.get(promptSchema, function (err, results) {
- done(err, !err && results.property);
- });
- },
-
- mixin: function (mixin, to) {
- Object.getOwnPropertyNames(mixin).forEach(function (prop) {
- if (Object.hasOwnProperty.call(mixin, prop)) {
- Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(mixin, prop));
- }
- });
- 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");
- }
- exit(ERROR_VALUE);
- } else {
- exit(0);
- }
- }
-
-};
-
-module.exports = _self;
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/942b81e7/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
new file mode 100644
index 0000000..df5e9b7
--- /dev/null
+++ b/blackberry10/bin/templates/project/cordova/lib/utils.js
@@ -0,0 +1,385 @@
+/*
+ * 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.
+ */
+
+/* globals Buffer */
+
+var fs = require('fs'),
+ exit = require('exit'),
+ async = require('async'),
+ path = require('path'),
+ childProcess = require('child_process'),
+ wrench = require('wrench'),
+ os = require('os'),
+ promptLib = require("prompt"),
+ DEFAULT_BAR_NAME = "bb10app",
+ PROPERTY_FILE_NAME = 'blackberry10.json',
+ CORDOVA_DIR = '.cordova',
+ ERROR_VALUE = 2,
+ DEFAULT_PROPERTY_FILE = {
+ targets: {
+ }
+ },
+ _self;
+
+function swapBytes(buffer) {
+ var l = buffer.length,
+ i,
+ a;
+
+ if (l % 2 === 0x01) {
+ throw new 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;
+ },
+
+ readdirSyncRecursive: function (baseDir) {
+ var files = [],
+ curFiles = [],
+ nextDirs,
+ isDir = function (f) {
+ return fs.statSync(f).isDirectory();
+ },
+ isFile = function (f) {
+ return !isDir(f);
+ },
+ prependBaseDir = function (fname) {
+ return path.join(baseDir, fname);
+ };
+
+ try {
+ curFiles = fs.readdirSync(baseDir);
+
+ if (curFiles && curFiles.length > 0) {
+ curFiles = curFiles.map(prependBaseDir);
+ nextDirs = curFiles.filter(isDir);
+ curFiles = curFiles.filter(isFile);
+
+ files = files.concat(curFiles);
+
+ while (nextDirs.length) {
+ files = files.concat(_self.readdirSyncRecursive(nextDirs.shift()));
+ }
+ }
+ } catch (e) {
+ }
+
+ return files;
+ },
+
+ isWindows: function () {
+ return os.type().toLowerCase().indexOf("windows") >= 0;
+ },
+
+ isOSX: function () {
+ return os.type().toLowerCase().indexOf("darwin") >= 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] ];
+ }
+ },
+
+ inQuotes : function (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 beginning 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] && 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;
+ //Use the process env by default
+ options.env = options.env || process.env;
+
+ 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) {
+ return require(path);
+ },
+
+ findHomePath : function () {
+ return process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'];
+ },
+
+ 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 () {
+ var props = require(_self.getPropertiesFilePath());
+ if (!props.targets) {
+ props.targets = {};
+ }
+ return props;
+ },
+
+ 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;
+ },
+
+ clone: function (original) {
+ var clone = {},
+ prop;
+ if (typeof original !== "object") {
+ clone = original;
+ } else if (Array.isArray(original)) {
+ clone = original.slice();
+ } else {
+ /* jshint ignore:start */
+ for (prop in original) {
+ clone[prop] = original[prop];
+ }
+ /* jshint ignore:end */
+ }
+
+ return clone;
+ },
+ prompt: function (options, done) {
+ var promptSchema = {
+ properties: {
+ "property": options
+ }
+ };
+ promptLib.start();
+ promptLib.colors = false;
+ promptLib.message = "";
+ promptLib.delimiter = "";
+ promptLib.get(promptSchema, function (err, results) {
+ done(err, !err && results.property);
+ });
+ },
+
+ mixin: function (mixin, to) {
+ Object.getOwnPropertyNames(mixin).forEach(function (prop) {
+ if (Object.hasOwnProperty.call(mixin, prop)) {
+ Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(mixin, prop));
+ }
+ });
+ 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");
+ }
+ exit(ERROR_VALUE);
+ } else {
+ exit(0);
+ }
+ }
+
+};
+
+module.exports = _self;
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/942b81e7/blackberry10/bin/test/cordova/integration/create.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/cordova/integration/create.js b/blackberry10/bin/test/cordova/integration/create.js
index d454b78..84f0805 100644
--- a/blackberry10/bin/test/cordova/integration/create.js
+++ b/blackberry10/bin/test/cordova/integration/create.js
@@ -21,7 +21,7 @@ var childProcess = require('child_process'),
tempFolder = '.tmp/',
appFolder = tempFolder + 'tempCordovaApp/',
wrench = require('wrench'),
- utils = require('../../../lib/utils'),
+ utils = require('../../../templates/project/cordova/lib/utils'),
path = require('path'),
fs = require('fs'),
shell = require("shelljs"),
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/942b81e7/blackberry10/bin/test/cordova/integration/target.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/cordova/integration/target.js b/blackberry10/bin/test/cordova/integration/target.js
index f74d648..5da16a3 100644
--- a/blackberry10/bin/test/cordova/integration/target.js
+++ b/blackberry10/bin/test/cordova/integration/target.js
@@ -21,7 +21,7 @@ var childProcess = require('child_process'),
tempFolder = '.tmp/',
appFolder = tempFolder + 'tempCordovaApp/',
wrench = require('wrench'),
- utils = require('../../../lib/utils'),
+ utils = require('../../../templates/project/cordova/lib/utils'),
fs = require('fs'),
path = require('path'),
shell = require("shelljs"),
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/942b81e7/blackberry10/scripts/test.js
----------------------------------------------------------------------
diff --git a/blackberry10/scripts/test.js b/blackberry10/scripts/test.js
index 537652c..a50e34e 100644
--- a/blackberry10/scripts/test.js
+++ b/blackberry10/scripts/test.js
@@ -24,7 +24,6 @@ module.exports = function (done, custom) {
"bin/test/cordova/integration",
"bin/test/cordova/unit"
];
- utils.copyFile('bin/lib/utils.js', 'bin/templates/project/cordova/lib/', '../');
jasmine.executeSpecsInFolder({
'specFolders': specs,
'onComplete': function (runner) {