You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2017/05/25 20:38:21 UTC
[01/25] cordova-browser git commit: don't exit and don't expect a
done()
Repository: cordova-browser
Updated Branches:
refs/heads/master 84dbb724f -> de5c08a3d
don't exit and don't expect a done()
Project: http://git-wip-us.apache.org/repos/asf/cordova-browser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-browser/commit/f1b136d0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-browser/tree/f1b136d0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-browser/diff/f1b136d0
Branch: refs/heads/master
Commit: f1b136d0958d2f85ea4c88f10ab7f757e5363e6c
Parents: 61f71c7
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu Apr 6 23:51:12 2017 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu Apr 6 23:51:12 2017 -0700
----------------------------------------------------------------------
bin/create | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/f1b136d0/bin/create
----------------------------------------------------------------------
diff --git a/bin/create b/bin/create
index b035022..b835820 100755
--- a/bin/create
+++ b/bin/create
@@ -29,7 +29,7 @@ if(args.length < 3 || (args[2] == '--help' || args[2] == '/?' || args[2] == '-h'
console.log(' <path_to_new_project>: Path to your new Cordova Browser project');
console.log(' <package_name>: Package name, following reverse-domain style convention');
console.log(' <project_name>: Project name');
- process.exit(1);
+ process.exitCode = 1;
} else {
- create.createProject(args[2], args[3], args[4], args[5]).done();
+ create.createProject(args[2], args[3], args[4], args[5]);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[03/25] cordova-browser git commit: large refactor, added PlatformApi,
deleted icons
Posted by pu...@apache.org.
large refactor, added PlatformApi, deleted icons
Project: http://git-wip-us.apache.org/repos/asf/cordova-browser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-browser/commit/3b4a52f6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-browser/tree/3b4a52f6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-browser/diff/3b4a52f6
Branch: refs/heads/master
Commit: 3b4a52f69132eeb384c3320755112575aadbe875
Parents: 44578d2
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Wed Apr 12 22:57:40 2017 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Wed Apr 12 22:57:40 2017 -0700
----------------------------------------------------------------------
.gitignore | 13 +-
bin/create | 83 ++++++++++--
bin/lib/check_reqs.js | 4 +-
bin/lib/create.js | 86 +++++++-----
bin/template/config.xml | 24 ++++
bin/template/cordova/Api.js | 135 +++++++++++++++++++
bin/template/cordova/build | 34 +++++
bin/template/cordova/build.bat | 26 ++++
bin/template/cordova/clean | 36 +++++
bin/template/cordova/defaults.xml | 22 +++
bin/template/cordova/lib/build.js | 64 +++++++++
bin/template/cordova/lib/clean.js | 55 ++++++++
bin/template/cordova/log | 20 +++
bin/template/cordova/run | 70 ++++++++++
bin/template/cordova/run.bat | 26 ++++
bin/template/cordova/version | 25 ++++
bin/template/cordova/version.bat | 26 ++++
bin/template/www/css/index.css | 115 ++++++++++++++++
bin/template/www/img/logo.png | Bin 0 -> 21814 bytes
bin/template/www/index.html | 43 ++++++
bin/template/www/js/index.js | 49 +++++++
bin/template/www/manifest.webapp | 10 ++
bin/templates/project/cordova/build | 34 -----
bin/templates/project/cordova/build.bat | 26 ----
bin/templates/project/cordova/clean | 37 -----
bin/templates/project/cordova/defaults.xml | 22 ---
bin/templates/project/cordova/lib/build.js | 65 ---------
bin/templates/project/cordova/lib/clean.js | 46 -------
bin/templates/project/cordova/run | 70 ----------
bin/templates/project/cordova/run.bat | 26 ----
bin/templates/project/cordova/version | 25 ----
bin/templates/project/cordova/version.bat | 26 ----
bin/templates/project/www/css/index.css | 115 ----------------
bin/templates/project/www/img/logo.png | Bin 21814 -> 0 bytes
bin/templates/project/www/index.html | 43 ------
bin/templates/project/www/js/index.js | 49 -------
bin/templates/project/www/manifest.webapp | 10 --
.../www/res/icon/android/icon-36-ldpi.png | Bin 3096 -> 0 bytes
.../www/res/icon/android/icon-48-mdpi.png | Bin 4090 -> 0 bytes
.../www/res/icon/android/icon-72-hdpi.png | Bin 6080 -> 0 bytes
.../www/res/icon/android/icon-96-xhdpi.png | Bin 7685 -> 0 bytes
.../www/res/icon/bada-wac/icon-48-type5.png | Bin 4111 -> 0 bytes
.../www/res/icon/bada-wac/icon-50-type3.png | Bin 5758 -> 0 bytes
.../www/res/icon/bada-wac/icon-80-type4.png | Bin 7287 -> 0 bytes
.../project/www/res/icon/bada/icon-128.png | Bin 11401 -> 0 bytes
.../project/www/res/icon/blackberry/icon-80.png | Bin 7287 -> 0 bytes
.../www/res/icon/blackberry10/icon-80.png | Bin 7287 -> 0 bytes
.../project/www/res/icon/ios/icon-57-2x.png | Bin 7869 -> 0 bytes
.../project/www/res/icon/ios/icon-57.png | Bin 3908 -> 0 bytes
.../project/www/res/icon/ios/icon-72-2x.png | Bin 11706 -> 0 bytes
.../project/www/res/icon/ios/icon-72.png | Bin 4944 -> 0 bytes
.../project/www/res/icon/tizen/icon-128.png | Bin 11401 -> 0 bytes
.../project/www/res/icon/webos/icon-64.png | Bin 5463 -> 0 bytes
.../res/icon/windows-phone/icon-173-tile.png | Bin 22878 -> 0 bytes
.../www/res/icon/windows-phone/icon-48.png | Bin 4111 -> 0 bytes
.../www/res/icon/windows-phone/icon-62-tile.png | Bin 7324 -> 0 bytes
package.json | 3 +-
57 files changed, 916 insertions(+), 647 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index a1eae77..ec8aba6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,8 +4,11 @@ temp
.gitcore
*.jar
-node_modules/.bin/jasmine-node
-node_modules/.bin/jshint
-node_modules/jasmine-node/
-node_modules/jshint/
-node_modules/tmp/
+node_modules/
+
+
+!node_modules/adm-zip
+!node_modules/cordova-serve
+!node_modules/nopt
+!node_modules/q
+!node_modules/shelljs
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/create
----------------------------------------------------------------------
diff --git a/bin/create b/bin/create
index b835820..5bd53f0 100755
--- a/bin/create
+++ b/bin/create
@@ -18,18 +18,75 @@
specific language governing permissions and limitations
under the License.
*/
+// var path = require('path');
+// var create = require('./lib/create');
+// var args = process.argv;
+
+// // Support basic help commands
+// if(args.length < 3 || (args[2] == '--help' || args[2] == '/?' || args[2] == '-h' ||
+// args[2] == 'help' || args[2] == '-help' || args[2] == '/help')) {
+// console.log('Usage: ' + path.relative(process.cwd(), path.join(__dirname, 'create')) + ' <path_to_new_project> <package_name> <project_name>');
+// console.log(' <path_to_new_project>: Path to your new Cordova Browser project');
+// console.log(' <package_name>: Package name, following reverse-domain style convention');
+// console.log(' <project_name>: Project name');
+// process.exitCode = 1;
+// } else {
+// create.createProject(args[2], args[3], args[4], args[5]);
+// }
+
+/*
+ * create a Cordova project
+ *
+ * USAGE
+ * ./create <path_to_new_project> <package_name> <project_name>
+ *
+ * EXAMPLE
+ * ./create ~/Desktop/radness org.apache.cordova.radness Radness
+ */
+
var path = require('path');
-var create = require('./lib/create');
-var args = process.argv;
-
-// Support basic help commands
-if(args.length < 3 || (args[2] == '--help' || args[2] == '/?' || args[2] == '-h' ||
- args[2] == 'help' || args[2] == '-help' || args[2] == '/help')) {
- console.log('Usage: ' + path.relative(process.cwd(), path.join(__dirname, 'create')) + ' <path_to_new_project> <package_name> <project_name>');
- console.log(' <path_to_new_project>: Path to your new Cordova Browser project');
- console.log(' <package_name>: Package name, following reverse-domain style convention');
- console.log(' <project_name>: Project name');
- process.exitCode = 1;
-} else {
- create.createProject(args[2], args[3], args[4], args[5]);
+var ConfigParser = require('cordova-common').ConfigParser;
+var Api = require('./template/cordova/Api');
+
+
+var argv = require('nopt')({
+ 'help' : Boolean,
+ 'cli' : Boolean,
+ 'shared' : Boolean, // alias for --link
+ 'link' : Boolean
+}, { 'd' : '--verbose' });
+
+
+var projectPath = argv.argv.remain[0];
+
+if (argv.help || !projectPath) {
+ console.log('Usage: $0 [--link] [--cli] <path_to_new_project> <package_name> <project_name> [<project_template_dir>]');
+ console.log(' --link (optional): Link directly against the shared copy of the CordovaLib instead of a copy of it.');
+ console.log(' --cli (optional): Use the CLI-project template.');
+ console.log(' <path_to_new_project>: Path to your new Cordova iOS project');
+ console.log(' <package_name>: Package name, following reverse-domain style convention');
+ console.log(' <project_name>: Project name');
+ console.log(' <project_template_dir>: Path to project template (override).');
+ process.exit(0);
}
+else {
+ var config = new ConfigParser(path.resolve(__dirname, 'template/config.xml'));
+
+ // apply overrides (package and project names
+ if (argv.argv.remain[1]) {
+ config.setPackageName(argv.argv.remain[1]);
+ }
+ if (argv.argv.remain[2]) {
+ config.setName(argv.argv.remain[2]);
+ }
+
+ var options = {
+ cli: argv.cli,
+ link: argv.link || argv.shared,
+ customTemplate: argv.argv.remain[3],
+ };
+
+ Api.createPlatform(projectPath, config, options);
+}
+
+
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/lib/check_reqs.js
----------------------------------------------------------------------
diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js
index 720d7aa..2743683 100644
--- a/bin/lib/check_reqs.js
+++ b/bin/lib/check_reqs.js
@@ -21,8 +21,6 @@ under the License.
//add methods as we determine what are the requirements
-var Q = require('q');
-
module.exports.run = function() {
- return Q.resolve();
+ return Promise.resolve();
};
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/bin/lib/create.js b/bin/lib/create.js
index 9b6e0ff..a7bb099 100644
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -18,66 +18,90 @@
* specific language governing permissions and limitations
* under the License.
*/
-
+
var fs = require('fs'),
- shjs = require('shelljs'),
- Q = require ('q'),
+ shell = require('shelljs'),
args = process.argv,
path = require('path'),
ROOT = path.join(__dirname, '..', '..'),
check_reqs = require('./check_reqs');
module.exports.createProject = function(project_path,package_name,project_name){
-
+
+ console.log("ROOT = " + ROOT);
+ console.log("browser :: createProject",project_path,package_name,project_name);
+
+
+/*
+ // create the dest and the standard place for our api to live
+ // platforms/platformName/cordova/Api.js
+
+ var apiSrcPath = __dirname; // default value
+ console.log("apiSrcPath " + apiSrcPath);
+ // does options contain the info we desire?
+
+ var projectName = config ? config.name() : "HelloCordova";
+
+ events.emit('log', 'Creating Cordova project for cordova-platform-test:');
+ events.emit('log', '\tPath: ' + dest);
+ events.emit('log', '\tName: ' + projectName);
+
+ shell.mkdir(dest);
+
+ // move a copy of our api to the new project
+ shell.cp('-r',apiSrcPath, dest);
+
+ // move our node_modules
+ var srcModulePath = path.join(__dirname,'../../../node_modules');
+ console.log("srcModulePath = " + srcModulePath);
+ shell.cp('-r',srcModulePath,path.join(dest,'cordova'));
+
+ // I promise I will return
+ return Promise.resolve(new Api(PLATFORM_NAME,dest,events));
+*/
+
var VERSION = fs.readFileSync(path.join(ROOT, 'VERSION'), 'utf-8');
-
+
// Set default values for path, package and name
- project_path = typeof project_path !== 'undefined' ? project_path : "CordovaExample";
+ project_path = project_path || "CordovaExample";
// Check if project already exists
if (fs.existsSync(project_path)) {
console.error('Project already exists! Delete and recreate');
- process.exit(2);
+ process.exitCode = 2;
+ return;
}
-
+
// Check that requirements are met and proper targets are installed
if (!check_reqs.run()) {
+ // TODO: use events.emit
console.error('Please make sure you meet the software requirements in order to build a browser cordova project');
- process.exit(2);
+ process.exitCode = 2;
+ return;
}
- console.log('Creating Browser project. Path: ' + path.relative(process.cwd(),project_path));
-
- //copy template directory
- shjs.cp('-r', path.join(ROOT, 'bin', 'templates', 'project', 'www'), project_path);
+ //copy template directory ( recursive )
+ //shell.cp('-r', path.join(ROOT, 'bin/templates/project/www'), project_path);
//create cordova/lib if it does not exist yet
- if (!fs.existsSync(path.join(project_path,'cordova', 'lib'))) {
- shjs.mkdir('-p', path.join(project_path,'cordova', 'lib'));
+ if (!fs.existsSync(path.join(project_path,'cordova/lib'))) {
+ shell.mkdir('-p', path.join(project_path,'cordova/lib'));
}
//copy required node_modules
- shjs.cp('-r', path.join(ROOT, 'node_modules'), path.join(project_path,'cordova'));
+ shell.cp('-r', path.join(ROOT, 'node_modules'), path.join(project_path,'cordova'));
//copy check_reqs file
- shjs.cp( path.join(ROOT, 'bin', 'lib', 'check_reqs.js'), path.join(project_path,'cordova', 'lib'));
-
+ shell.cp( path.join(ROOT, 'bin/lib/check_reqs.js'), path.join(project_path,'cordova/lib'));
+
//copy cordova js file
- shjs.cp('-r', path.join(ROOT, 'cordova-lib', 'cordova.js'), path.join(project_path,'www'));
+ shell.cp('-r', path.join(ROOT, 'cordova-lib', 'cordova.js'), path.join(project_path,'www'));
//copy cordova-js-src directory
- shjs.cp('-rf', path.join(ROOT, 'cordova-js-src'), path.join(project_path, 'platform_www'));
+ shell.cp('-rf', path.join(ROOT, 'cordova-js-src'), path.join(project_path, 'platform_www'));
//copy cordova directory
- shjs.cp('-r', path.join(ROOT, 'bin', 'templates', 'project', 'cordova'), project_path);
- [
- 'run',
- 'build',
- 'clean',
- 'version',
- ].forEach(function(f) {
- shjs.chmod(755, path.join(project_path, 'cordova', f));
- });
-
- return Q.resolve();
+ shell.cp('-r', path.join(ROOT, 'bin/template/cordova'), project_path);
+
+ return Promise.resolve();
};
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/template/config.xml
----------------------------------------------------------------------
diff --git a/bin/template/config.xml b/bin/template/config.xml
new file mode 100644
index 0000000..a212661
--- /dev/null
+++ b/bin/template/config.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+#
+-->
+<widget xmlns="http://www.w3.org/ns/widgets">
+
+</widget>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/template/cordova/Api.js
----------------------------------------------------------------------
diff --git a/bin/template/cordova/Api.js b/bin/template/cordova/Api.js
new file mode 100644
index 0000000..b137606
--- /dev/null
+++ b/bin/template/cordova/Api.js
@@ -0,0 +1,135 @@
+/*
+ this file is found by cordova-lib when you attempt to
+ 'cordova platform add PATH' where path is this repo.
+*/
+
+/*jslint node: true */
+
+var shell = require('shelljs');
+var path = require('path');
+
+var CordovaLogger = require('cordova-common').CordovaLogger;
+var selfEvents = require('cordova-common').events;
+
+var PLATFORM_NAME = 'testplatform';
+
+function setupEvents(externalEventEmitter) {
+ if (externalEventEmitter) {
+ // This will make the platform internal events visible outside
+ selfEvents.forwardEventsTo(externalEventEmitter);
+ return externalEventEmitter;
+ }
+
+ // There is no logger if external emitter is not present,
+ // so attach a console logger
+ CordovaLogger.get().subscribe(selfEvents);
+ return selfEvents;
+}
+
+function Api(platform, platformRootDir, events) {
+
+ this.platform = platform || PLATFORM_NAME;
+ this.root = path.resolve(__dirname, '..');
+
+ this.locations = {
+ platformRootDir: platformRootDir,
+ root: this.root,
+ www: path.join(this.root, 'assets/www'),
+ res: path.join(this.root, 'res'),
+ platformWww: path.join(this.root, 'platform_www'),
+ configXml: path.join(this.root, 'res/xml/config.xml'),
+ defaultConfigXml: path.join(this.root, 'cordova/defaults.xml'),
+ build: path.join(this.root, 'build'),
+ // NOTE: Due to platformApi spec we need to return relative paths here
+ cordovaJs: 'bin/templates/project/assets/www/cordova.js',
+ cordovaJsSrc: 'cordova-js-src'
+ };
+
+}
+
+Api.createPlatform = function (dest, config, options, events) {
+
+ console.log("browser createPlatform !! dest:" + dest);
+
+ events = setupEvents(events);
+ var name = config.name();
+ var result;
+ try {
+
+ var creator = require('../../lib/create');
+ console.log("creator = " + creator);
+ result = creator.createProject(dest, config.packageName(), name, options)
+ .then(function () {
+ // after platform is created we return Api instance based on new Api.js location
+ // This is required to correctly resolve paths in the future api calls
+ var PlatformApi = require(path.resolve(dest, 'cordova/Api'));
+ return new PlatformApi('browser', dest, events);
+ });
+ }
+ catch(e) {
+ console.log("error : " + e);
+ events.emit('error','createPlatform is not callable from the browser project API.');
+ throw(e);
+ }
+ return result;
+
+
+};
+
+
+Api.updatePlatform = function (dest, options, events) {
+ // console.log("test-platform:Api:updatePlatform");
+ // todo?: create projectInstance and fulfill promise with it.
+ return Promise.resolve();
+};
+
+Api.prototype.getPlatformInfo = function () {
+ console.log("browser-platform:Api:getPlatformInfo");
+ // return PlatformInfo object
+
+ return {
+ "locations":this.locations,
+ "root": this.root,
+ "name": this.platform,
+ "version": { "version" : "1.0.0" },
+ "projectConfig": this._config
+ };
+};
+
+Api.prototype.prepare = function (cordovaProject) {
+ console.log("browser-platform:Api:prepare");
+ return Promise.resolve();
+};
+
+Api.prototype.addPlugin = function (plugin, installOptions) {
+ console.log("browser-platform:Api:addPlugin");
+ return Promise.resolve();
+};
+
+Api.prototype.removePlugin = function (plugin, uninstallOptions) {
+ console.log("browser-platform:Api:removePlugin");
+ return Promise.resolve();
+};
+
+Api.prototype.build = function (buildOptions) {
+ console.log("API building this shit");
+ var self = this;
+ return require('./lib/check_reqs').run()
+ .then(function () {
+ return require('./lib/build').run.call(self, buildOptions);
+ });
+};
+
+Api.prototype.run = function(runOptions) {
+
+};
+
+Api.prototype.clean = function(cleanOptions) {
+ return require('./lib/clean').run();
+};
+
+Api.prototype.requirements = function() {
+ return require('./lib/check_reqs').run();
+};
+
+module.exports = Api;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/template/cordova/build
----------------------------------------------------------------------
diff --git a/bin/template/cordova/build b/bin/template/cordova/build
new file mode 100755
index 0000000..e867ab1
--- /dev/null
+++ b/bin/template/cordova/build
@@ -0,0 +1,34 @@
+#!/usr/bin/env node
+
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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 build = require('./lib/build'),
+ args = process.argv;
+
+// provide help
+if ( args[2] == '--help' || args[2] == '/?' || args[2] == '-h' || args[2] == '/h' ||
+ args[2] == 'help' || args[2] == '-help' || args[2] == '/help') {
+ build.help();
+ process.exit(0);
+} else {
+
+ build.run();
+}
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/template/cordova/build.bat
----------------------------------------------------------------------
diff --git a/bin/template/cordova/build.bat b/bin/template/cordova/build.bat
new file mode 100644
index 0000000..02641bc
--- /dev/null
+++ b/bin/template/cordova/build.bat
@@ -0,0 +1,26 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements. See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership. The ASF licenses this file
+:: to you 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.
+
+@ECHO OFF
+SET script_path="%~dp0build"
+IF EXIST %script_path% (
+ node %script_path% %*
+) ELSE (
+ ECHO.
+ ECHO ERROR: Could not find 'build' script in 'cordova' folder, aborting...>&2
+ EXIT /B 1
+)
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/template/cordova/clean
----------------------------------------------------------------------
diff --git a/bin/template/cordova/clean b/bin/template/cordova/clean
new file mode 100644
index 0000000..1852d66
--- /dev/null
+++ b/bin/template/cordova/clean
@@ -0,0 +1,36 @@
+#!/usr/bin/env node
+
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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 path = require('path'),
+ clean = require('./lib/clean'),
+ args = process.argv;
+
+// Support basic help commands
+if ( args.length > 2
+ || args[2] == '--help' || args[2] == '/?' || args[2] == '-h' ||
+ args[2] == 'help' || args[2] == '-help' || args[2] == '/help') {
+ console.log('Usage: ' + path.relative(process.cwd(), path.join(__dirname, 'clean')) );
+ process.exit(0);
+} else {
+ clean.run();
+}
+
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/template/cordova/defaults.xml
----------------------------------------------------------------------
diff --git a/bin/template/cordova/defaults.xml b/bin/template/cordova/defaults.xml
new file mode 100644
index 0000000..a7b31c0
--- /dev/null
+++ b/bin/template/cordova/defaults.xml
@@ -0,0 +1,22 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
+
+</widget>
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/template/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/bin/template/cordova/lib/build.js b/bin/template/cordova/lib/build.js
new file mode 100644
index 0000000..c591354
--- /dev/null
+++ b/bin/template/cordova/lib/build.js
@@ -0,0 +1,64 @@
+#!/usr/bin/env node
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 path = require('path'),
+ fs = require('fs'),
+ shjs = require('shelljs'),
+ zip = require('adm-zip'),
+ clean = require('./clean'),
+ check_reqs = require('./check_reqs'),
+ platformWwwDir = path.join('platforms', 'browser', 'www'),
+ platformBuildDir = path.join('platforms', 'browser', 'build'),
+ packageFile = path.join(platformBuildDir, 'package.zip');
+
+/**
+ * run
+ * Creates a zip file int platform/build folder
+ */
+module.exports.run = function(){
+
+ return check_reqs.run()
+ .then(function(){
+ return clean.run();
+ },
+ function checkReqsError(err){
+ console.error('Please make sure you meet the software requirements in order to build a browser cordova project');
+ })
+ .then(function(){
+
+ if (!fs.existsSync(platformBuildDir)) {
+ fs.mkdirSync(platformBuildDir);
+ }
+
+ // add the project to a zipfile
+ var zipFile = zip();
+ zipFile.addLocalFolder(platformWwwDir, '.');
+ zipFile.writeZip(packageFile);
+
+ return Promise.resolve();
+
+ });
+};
+
+module.exports.help = function() {
+ console.log('Usage: cordova build browser');
+ console.log('Build will create the packaged app in \''+platformBuildDir+'\'.');
+};
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/template/cordova/lib/clean.js
----------------------------------------------------------------------
diff --git a/bin/template/cordova/lib/clean.js b/bin/template/cordova/lib/clean.js
new file mode 100644
index 0000000..dff4c06
--- /dev/null
+++ b/bin/template/cordova/lib/clean.js
@@ -0,0 +1,55 @@
+#!/usr/bin/env node
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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'),
+ shell = require('shelljs'),
+ path = require('path'),
+ check_reqs = require('./check_reqs'),
+ platformBuildDir = path.join('platforms', 'browser', 'build');
+
+var run = function(){
+
+ console.log("cleaning ... ");
+ // Check that requirements are (still) met
+ if (!check_reqs.run()) {
+ console.error('Please make sure you meet the software requirements in order to clean an browser cordova project');
+ process.exit(2);
+ }
+
+ console.log('Cleaning Browser project');
+
+ try {
+ if (fs.existsSync(platformBuildDir)) {
+ shell.rm('-r', platformBuildDir);
+ }
+ }
+ catch(err) {
+ console.log('could not remove '+platformBuildDir+' : '+err.message);
+ }
+};
+
+module.exports.run = run;
+// just on the off chance something is still calling cleanProject, we will leave this here for a while
+module.exports.cleanProject = function(){
+ console.log("lib/clean will soon only export a `run` command, please update to not call `cleanProject`.");
+ return run();
+}
+
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/template/cordova/log
----------------------------------------------------------------------
diff --git a/bin/template/cordova/log b/bin/template/cordova/log
new file mode 100755
index 0000000..bb6fb8c
--- /dev/null
+++ b/bin/template/cordova/log
@@ -0,0 +1,20 @@
+#!/usr/bin/env node
+
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+*/
+
+console.log("cordova/log");
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/template/cordova/run
----------------------------------------------------------------------
diff --git a/bin/template/cordova/run b/bin/template/cordova/run
new file mode 100755
index 0000000..29c73bc
--- /dev/null
+++ b/bin/template/cordova/run
@@ -0,0 +1,70 @@
+#!/usr/bin/env node
+
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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'),
+ nopt = require('nopt'),
+ url = require('url'),
+ cordovaServe = require('cordova-serve');
+
+var args = process.argv;
+
+start(args);
+
+function start(argv) {
+ var args = nopt({'help': Boolean, 'target': String, 'port': Number}, {'help': ['/?', '-h', 'help', '-help', '/help']}, argv);
+ if(args.help) {
+ help();
+ }
+
+ // defaults
+ args.port = args.port || 8000;
+ args.target = args.target || "chrome"; // make default the system browser
+
+ var root = path.join(__dirname, '../'),
+ configFile = path.resolve(path.join(root, 'config.xml')),
+ configXML = fs.readFileSync(configFile, 'utf8'),
+ sourceFile = /<content[\s]+?src\s*=\s*"(.*?)"/i.exec(configXML);
+
+ var server = cordovaServe(); // Who wrote this? JavaScript much?
+ server.servePlatform('browser', {port: args.port, noServerInfo: true}).then(function () {
+ var projectUrl = url.resolve('http://localhost:' + server.port + '/', sourceFile ? sourceFile[1] : 'index.html');
+ console.log('Static file server running @ ' + projectUrl + '\nCTRL + C to shut down');
+ return cordovaServe.launchBrowser({target: args.target, url: projectUrl});
+ }).catch(function (error) {
+ console.log(error.message || error.toString());
+ if (server.server) {
+ server.server.close();
+ }
+ });
+}
+
+function help() {
+ console.log("\nUsage: run [ --target=<browser> ] [ --port=<number> ]");
+ console.log(" --target=<browser> : Launches the specified browser. Chrome is default.");
+ console.log(" --port=<number> : Http server uses specified port number.");
+ console.log("Examples:");
+ console.log(" run");
+ console.log(" run -- --target=ie");
+ console.log(" run -- --target=chrome --port=8000");
+ console.log("");
+ process.exit(0);
+}
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/template/cordova/run.bat
----------------------------------------------------------------------
diff --git a/bin/template/cordova/run.bat b/bin/template/cordova/run.bat
new file mode 100644
index 0000000..b9c4402
--- /dev/null
+++ b/bin/template/cordova/run.bat
@@ -0,0 +1,26 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements. See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership. The ASF licenses this file
+:: to you 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.
+
+@ECHO OFF
+SET script_path="%~dp0run"
+IF EXIST %script_path% (
+ node %script_path% %*
+) ELSE (
+ ECHO.
+ ECHO ERROR: Could not find 'run' script in 'cordova' folder, aborting...>&2
+ EXIT /B 1
+)
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/template/cordova/version
----------------------------------------------------------------------
diff --git a/bin/template/cordova/version b/bin/template/cordova/version
new file mode 100755
index 0000000..8acf18f
--- /dev/null
+++ b/bin/template/cordova/version
@@ -0,0 +1,25 @@
+#!/usr/bin/env node
+
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+*/
+
+// Coho updates this line:
+var VERSION = "4.2.0-dev";
+
+console.log(VERSION);
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/template/cordova/version.bat
----------------------------------------------------------------------
diff --git a/bin/template/cordova/version.bat b/bin/template/cordova/version.bat
new file mode 100644
index 0000000..3610c17
--- /dev/null
+++ b/bin/template/cordova/version.bat
@@ -0,0 +1,26 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements. See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership. The ASF licenses this file
+:: to you 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.
+
+@ECHO OFF
+SET script_path="%~dp0version"
+IF EXIST %script_path% (
+ node %script_path% %*
+) ELSE (
+ ECHO.
+ ECHO ERROR: Could not find 'version' script in 'cordova' folder, aborting...>&2
+ EXIT /B 1
+)
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/template/www/css/index.css
----------------------------------------------------------------------
diff --git a/bin/template/www/css/index.css b/bin/template/www/css/index.css
new file mode 100644
index 0000000..51daa79
--- /dev/null
+++ b/bin/template/www/css/index.css
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+* {
+ -webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */
+}
+
+body {
+ -webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to hold */
+ -webkit-text-size-adjust: none; /* prevent webkit from resizing text to fit */
+ -webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */
+ background-color:#E4E4E4;
+ background-image:linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
+ background-image:-webkit-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
+ background-image:-ms-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
+ background-image:-webkit-gradient(
+ linear,
+ left top,
+ left bottom,
+ color-stop(0, #A7A7A7),
+ color-stop(0.51, #E4E4E4)
+ );
+ background-attachment:fixed;
+ font-family:'HelveticaNeue-Light', 'HelveticaNeue', Helvetica, Arial, sans-serif;
+ font-size:12px;
+ height:100%;
+ margin:0px;
+ padding:0px;
+ text-transform:uppercase;
+ width:100%;
+}
+
+/* Portrait layout (default) */
+.app {
+ background:url(../img/logo.png) no-repeat center top; /* 170px x 200px */
+ position:absolute; /* position in the center of the screen */
+ left:50%;
+ top:50%;
+ height:50px; /* text area height */
+ width:225px; /* text area width */
+ text-align:center;
+ padding:180px 0px 0px 0px; /* image height is 200px (bottom 20px are overlapped with text) */
+ margin:-115px 0px 0px -112px; /* offset vertical: half of image height and text area height */
+ /* offset horizontal: half of text area width */
+}
+
+/* Landscape layout (with min-width) */
+@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) {
+ .app {
+ background-position:left center;
+ padding:75px 0px 75px 170px; /* padding-top + padding-bottom + text area = image height */
+ margin:-90px 0px 0px -198px; /* offset vertical: half of image height */
+ /* offset horizontal: half of image width and text area width */
+ }
+}
+
+h1 {
+ font-size:24px;
+ font-weight:normal;
+ margin:0px;
+ overflow:visible;
+ padding:0px;
+ text-align:center;
+}
+
+.event {
+ border-radius:4px;
+ -webkit-border-radius:4px;
+ color:#FFFFFF;
+ font-size:12px;
+ margin:0px 30px;
+ padding:2px 0px;
+}
+
+.event.listening {
+ background-color:#333333;
+ display:block;
+}
+
+.event.received {
+ background-color:#4B946A;
+ display:none;
+}
+
+@keyframes fade {
+ from { opacity: 1.0; }
+ 50% { opacity: 0.4; }
+ to { opacity: 1.0; }
+}
+
+@-webkit-keyframes fade {
+ from { opacity: 1.0; }
+ 50% { opacity: 0.4; }
+ to { opacity: 1.0; }
+}
+
+.blink {
+ animation:fade 3000ms infinite;
+ -webkit-animation:fade 3000ms infinite;
+}
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/template/www/img/logo.png
----------------------------------------------------------------------
diff --git a/bin/template/www/img/logo.png b/bin/template/www/img/logo.png
new file mode 100644
index 0000000..9519e7d
Binary files /dev/null and b/bin/template/www/img/logo.png differ
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/template/www/index.html
----------------------------------------------------------------------
diff --git a/bin/template/www/index.html b/bin/template/www/index.html
new file mode 100644
index 0000000..bde5741
--- /dev/null
+++ b/bin/template/www/index.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <meta name="format-detection" content="telephone=no" />
+ <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
+ <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
+ <link rel="stylesheet" type="text/css" href="css/index.css" />
+ <title>Hello World</title>
+ </head>
+ <body>
+ <div class="app">
+ <h1>Apache Cordova</h1>
+ <div id="deviceready" class="blink">
+ <p class="event listening">Connecting to Device</p>
+ <p class="event received">Device is Ready</p>
+ </div>
+ </div>
+ <script type="text/javascript" src="cordova.js"></script>
+ <script type="text/javascript" src="js/index.js"></script>
+ <script type="text/javascript">
+ app.initialize();
+ </script>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/template/www/js/index.js
----------------------------------------------------------------------
diff --git a/bin/template/www/js/index.js b/bin/template/www/js/index.js
new file mode 100644
index 0000000..31d9064
--- /dev/null
+++ b/bin/template/www/js/index.js
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 app = {
+ // Application Constructor
+ initialize: function() {
+ this.bindEvents();
+ },
+ // Bind Event Listeners
+ //
+ // Bind any events that are required on startup. Common events are:
+ // 'load', 'deviceready', 'offline', and 'online'.
+ bindEvents: function() {
+ document.addEventListener('deviceready', this.onDeviceReady, false);
+ },
+ // deviceready Event Handler
+ //
+ // The scope of 'this' is the event. In order to call the 'receivedEvent'
+ // function, we must explicity call 'app.receivedEvent(...);'
+ onDeviceReady: function() {
+ app.receivedEvent('deviceready');
+ },
+ // Update DOM on a Received Event
+ receivedEvent: function(id) {
+ var parentElement = document.getElementById(id);
+ var listeningElement = parentElement.querySelector('.listening');
+ var receivedElement = parentElement.querySelector('.received');
+
+ listeningElement.setAttribute('style', 'display:none;');
+ receivedElement.setAttribute('style', 'display:block;');
+
+ console.log('Received Event: ' + id);
+ }
+};
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/template/www/manifest.webapp
----------------------------------------------------------------------
diff --git a/bin/template/www/manifest.webapp b/bin/template/www/manifest.webapp
new file mode 100644
index 0000000..f24deb8
--- /dev/null
+++ b/bin/template/www/manifest.webapp
@@ -0,0 +1,10 @@
+{
+ "name": "My App",
+ "description": "Description of your app",
+ "launch_path": "/index.html",
+ "icons": {
+ "128": "/img/logo.png"
+ },
+ "default_locale": "en",
+ "type": "privileged"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/cordova/build
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/build b/bin/templates/project/cordova/build
deleted file mode 100755
index e867ab1..0000000
--- a/bin/templates/project/cordova/build
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/env node
-
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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 build = require('./lib/build'),
- args = process.argv;
-
-// provide help
-if ( args[2] == '--help' || args[2] == '/?' || args[2] == '-h' || args[2] == '/h' ||
- args[2] == 'help' || args[2] == '-help' || args[2] == '/help') {
- build.help();
- process.exit(0);
-} else {
-
- build.run();
-}
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/cordova/build.bat
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/build.bat b/bin/templates/project/cordova/build.bat
deleted file mode 100644
index 02641bc..0000000
--- a/bin/templates/project/cordova/build.bat
+++ /dev/null
@@ -1,26 +0,0 @@
-:: Licensed to the Apache Software Foundation (ASF) under one
-:: or more contributor license agreements. See the NOTICE file
-:: distributed with this work for additional information
-:: regarding copyright ownership. The ASF licenses this file
-:: to you 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.
-
-@ECHO OFF
-SET script_path="%~dp0build"
-IF EXIST %script_path% (
- node %script_path% %*
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find 'build' script in 'cordova' folder, aborting...>&2
- EXIT /B 1
-)
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/cordova/clean
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/clean b/bin/templates/project/cordova/clean
deleted file mode 100644
index da21bc7..0000000
--- a/bin/templates/project/cordova/clean
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/env node
-
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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 path = require('path'),
- clean = require('./lib/clean'),
- reqs = require('./lib/check_reqs'),
- args = process.argv;
-
-// Support basic help commands
-if ( args.length > 2
- || args[2] == '--help' || args[2] == '/?' || args[2] == '-h' ||
- args[2] == 'help' || args[2] == '-help' || args[2] == '/help') {
- console.log('Usage: ' + path.relative(process.cwd(), path.join(__dirname, 'clean')) );
- process.exit(0);
-} else {
- clean.cleanProject();
-}
-
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/cordova/defaults.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/defaults.xml b/bin/templates/project/cordova/defaults.xml
deleted file mode 100644
index a7b31c0..0000000
--- a/bin/templates/project/cordova/defaults.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
-
-</widget>
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/build.js b/bin/templates/project/cordova/lib/build.js
deleted file mode 100644
index fde7519..0000000
--- a/bin/templates/project/cordova/lib/build.js
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/env node
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 path = require('path'),
- fs = require('fs'),
- shjs = require('shelljs'),
- zip = require('adm-zip'),
- Q = require('q'),
- clean = require('./clean'),
- check_reqs = require('./check_reqs'),
- platformWwwDir = path.join('platforms', 'browser', 'www'),
- platformBuildDir = path.join('platforms', 'browser', 'build'),
- packageFile = path.join(platformBuildDir, 'package.zip');
-
-/**
- * run
- * Creates a zip file int platform/build folder
- */
-module.exports.run = function(){
-
- return check_reqs.run()
- .then(function(){
- return clean.cleanProject();
- },
- function checkReqsError(err){
- console.error('Please make sure you meet the software requirements in order to build a browser cordova project');
- })
- .then(function(){
-
- if (!fs.existsSync(platformBuildDir)) {
- fs.mkdirSync(platformBuildDir);
- }
-
- // add the project to a zipfile
- var zipFile = zip();
- zipFile.addLocalFolder(platformWwwDir, '.');
- zipFile.writeZip(packageFile);
-
- return Q.resolve();
-
- });
-};
-
-module.exports.help = function() {
- console.log('Usage: cordova build browser');
- console.log('Build will create the packaged app in \''+platformBuildDir+'\'.');
-};
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/cordova/lib/clean.js
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/clean.js b/bin/templates/project/cordova/lib/clean.js
deleted file mode 100644
index 2e4367d..0000000
--- a/bin/templates/project/cordova/lib/clean.js
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/env node
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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'),
- shjs = require('shelljs'),
- path = require('path'),
- check_reqs = require('./check_reqs'),
- platformBuildDir = path.join('platforms', 'browser', 'build');
-
-exports.cleanProject = function(){
-
- // Check that requirements are (stil) met
- if (!check_reqs.run()) {
- console.error('Please make sure you meet the software requirements in order to clean an browser cordova project');
- process.exit(2);
- }
-
- console.log('Cleaning Browser project');
- try {
- if (fs.existsSync(platformBuildDir)) {
- shjs.rm('-r', platformBuildDir);
- }
- }
- catch(err) {
- console.log('could not remove '+platformBuildDir+' : '+err.message);
- }
-};
-
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/cordova/run
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/run b/bin/templates/project/cordova/run
deleted file mode 100755
index d4c690b..0000000
--- a/bin/templates/project/cordova/run
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/env node
-
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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'),
- nopt = require('nopt'),
- url = require('url'),
- cordovaServe = require('cordova-serve');
-
-var args = process.argv;
-
-start(args);
-
-function start(argv) {
- var args = nopt({'help': Boolean, 'target': String, 'port': Number}, {'help': ['/?', '-h', 'help', '-help', '/help']}, argv);
- if(args.help) {
- help();
- }
-
- // defaults
- args.port = args.port || 8000;
- args.target = args.target || "chrome";
-
- var root = path.join(__dirname, '../'),
- configFile = path.resolve(path.join(root, 'config.xml')),
- configXML = fs.readFileSync(configFile, 'utf8'),
- sourceFile = /<content[\s]+?src\s*=\s*"(.*?)"/i.exec(configXML);
-
- var server = cordovaServe();
- server.servePlatform('browser', {port: args.port, noServerInfo: true}).then(function () {
- var projectUrl = url.resolve('http://localhost:' + server.port + '/', sourceFile ? sourceFile[1] : 'index.html');
- console.log('Static file server running @ ' + projectUrl + '\nCTRL + C to shut down');
- return cordovaServe.launchBrowser({target: args.target, url: projectUrl});
- }).catch(function (error) {
- console.log(error.message || error.toString());
- if (server.server) {
- server.server.close();
- }
- });
-}
-
-function help() {
- console.log("\nUsage: run [ --target=<browser> ] [ --port=<number> ]");
- console.log(" --target=<browser> : Launches the specified browser. Chrome is default.");
- console.log(" --port=<number> : Http server uses specified port number.");
- console.log("Examples:");
- console.log(" run");
- console.log(" run -- --target=ie");
- console.log(" run -- --target=chrome --port=8000");
- console.log("");
- process.exit(0);
-}
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/cordova/run.bat
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/run.bat b/bin/templates/project/cordova/run.bat
deleted file mode 100644
index b9c4402..0000000
--- a/bin/templates/project/cordova/run.bat
+++ /dev/null
@@ -1,26 +0,0 @@
-:: Licensed to the Apache Software Foundation (ASF) under one
-:: or more contributor license agreements. See the NOTICE file
-:: distributed with this work for additional information
-:: regarding copyright ownership. The ASF licenses this file
-:: to you 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.
-
-@ECHO OFF
-SET script_path="%~dp0run"
-IF EXIST %script_path% (
- node %script_path% %*
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find 'run' script in 'cordova' folder, aborting...>&2
- EXIT /B 1
-)
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/cordova/version
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/version b/bin/templates/project/cordova/version
deleted file mode 100755
index 8acf18f..0000000
--- a/bin/templates/project/cordova/version
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/env node
-
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
-*/
-
-// Coho updates this line:
-var VERSION = "4.2.0-dev";
-
-console.log(VERSION);
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/cordova/version.bat
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/version.bat b/bin/templates/project/cordova/version.bat
deleted file mode 100644
index 3610c17..0000000
--- a/bin/templates/project/cordova/version.bat
+++ /dev/null
@@ -1,26 +0,0 @@
-:: Licensed to the Apache Software Foundation (ASF) under one
-:: or more contributor license agreements. See the NOTICE file
-:: distributed with this work for additional information
-:: regarding copyright ownership. The ASF licenses this file
-:: to you 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.
-
-@ECHO OFF
-SET script_path="%~dp0version"
-IF EXIST %script_path% (
- node %script_path% %*
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find 'version' script in 'cordova' folder, aborting...>&2
- EXIT /B 1
-)
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/css/index.css
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/css/index.css b/bin/templates/project/www/css/index.css
deleted file mode 100644
index 51daa79..0000000
--- a/bin/templates/project/www/css/index.css
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-* {
- -webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */
-}
-
-body {
- -webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to hold */
- -webkit-text-size-adjust: none; /* prevent webkit from resizing text to fit */
- -webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */
- background-color:#E4E4E4;
- background-image:linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
- background-image:-webkit-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
- background-image:-ms-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
- background-image:-webkit-gradient(
- linear,
- left top,
- left bottom,
- color-stop(0, #A7A7A7),
- color-stop(0.51, #E4E4E4)
- );
- background-attachment:fixed;
- font-family:'HelveticaNeue-Light', 'HelveticaNeue', Helvetica, Arial, sans-serif;
- font-size:12px;
- height:100%;
- margin:0px;
- padding:0px;
- text-transform:uppercase;
- width:100%;
-}
-
-/* Portrait layout (default) */
-.app {
- background:url(../img/logo.png) no-repeat center top; /* 170px x 200px */
- position:absolute; /* position in the center of the screen */
- left:50%;
- top:50%;
- height:50px; /* text area height */
- width:225px; /* text area width */
- text-align:center;
- padding:180px 0px 0px 0px; /* image height is 200px (bottom 20px are overlapped with text) */
- margin:-115px 0px 0px -112px; /* offset vertical: half of image height and text area height */
- /* offset horizontal: half of text area width */
-}
-
-/* Landscape layout (with min-width) */
-@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) {
- .app {
- background-position:left center;
- padding:75px 0px 75px 170px; /* padding-top + padding-bottom + text area = image height */
- margin:-90px 0px 0px -198px; /* offset vertical: half of image height */
- /* offset horizontal: half of image width and text area width */
- }
-}
-
-h1 {
- font-size:24px;
- font-weight:normal;
- margin:0px;
- overflow:visible;
- padding:0px;
- text-align:center;
-}
-
-.event {
- border-radius:4px;
- -webkit-border-radius:4px;
- color:#FFFFFF;
- font-size:12px;
- margin:0px 30px;
- padding:2px 0px;
-}
-
-.event.listening {
- background-color:#333333;
- display:block;
-}
-
-.event.received {
- background-color:#4B946A;
- display:none;
-}
-
-@keyframes fade {
- from { opacity: 1.0; }
- 50% { opacity: 0.4; }
- to { opacity: 1.0; }
-}
-
-@-webkit-keyframes fade {
- from { opacity: 1.0; }
- 50% { opacity: 0.4; }
- to { opacity: 1.0; }
-}
-
-.blink {
- animation:fade 3000ms infinite;
- -webkit-animation:fade 3000ms infinite;
-}
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/img/logo.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/img/logo.png b/bin/templates/project/www/img/logo.png
deleted file mode 100644
index 9519e7d..0000000
Binary files a/bin/templates/project/www/img/logo.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/index.html
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/index.html b/bin/templates/project/www/index.html
deleted file mode 100644
index bde5741..0000000
--- a/bin/templates/project/www/index.html
+++ /dev/null
@@ -1,43 +0,0 @@
-<!DOCTYPE html>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<html>
- <head>
- <meta charset="utf-8" />
- <meta name="format-detection" content="telephone=no" />
- <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
- <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
- <link rel="stylesheet" type="text/css" href="css/index.css" />
- <title>Hello World</title>
- </head>
- <body>
- <div class="app">
- <h1>Apache Cordova</h1>
- <div id="deviceready" class="blink">
- <p class="event listening">Connecting to Device</p>
- <p class="event received">Device is Ready</p>
- </div>
- </div>
- <script type="text/javascript" src="cordova.js"></script>
- <script type="text/javascript" src="js/index.js"></script>
- <script type="text/javascript">
- app.initialize();
- </script>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/js/index.js
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/js/index.js b/bin/templates/project/www/js/index.js
deleted file mode 100644
index 31d9064..0000000
--- a/bin/templates/project/www/js/index.js
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 app = {
- // Application Constructor
- initialize: function() {
- this.bindEvents();
- },
- // Bind Event Listeners
- //
- // Bind any events that are required on startup. Common events are:
- // 'load', 'deviceready', 'offline', and 'online'.
- bindEvents: function() {
- document.addEventListener('deviceready', this.onDeviceReady, false);
- },
- // deviceready Event Handler
- //
- // The scope of 'this' is the event. In order to call the 'receivedEvent'
- // function, we must explicity call 'app.receivedEvent(...);'
- onDeviceReady: function() {
- app.receivedEvent('deviceready');
- },
- // Update DOM on a Received Event
- receivedEvent: function(id) {
- var parentElement = document.getElementById(id);
- var listeningElement = parentElement.querySelector('.listening');
- var receivedElement = parentElement.querySelector('.received');
-
- listeningElement.setAttribute('style', 'display:none;');
- receivedElement.setAttribute('style', 'display:block;');
-
- console.log('Received Event: ' + id);
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/manifest.webapp
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/manifest.webapp b/bin/templates/project/www/manifest.webapp
deleted file mode 100644
index f24deb8..0000000
--- a/bin/templates/project/www/manifest.webapp
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "name": "My App",
- "description": "Description of your app",
- "launch_path": "/index.html",
- "icons": {
- "128": "/img/logo.png"
- },
- "default_locale": "en",
- "type": "privileged"
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/res/icon/android/icon-36-ldpi.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/res/icon/android/icon-36-ldpi.png b/bin/templates/project/www/res/icon/android/icon-36-ldpi.png
deleted file mode 100644
index cd5032a..0000000
Binary files a/bin/templates/project/www/res/icon/android/icon-36-ldpi.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/res/icon/android/icon-48-mdpi.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/res/icon/android/icon-48-mdpi.png b/bin/templates/project/www/res/icon/android/icon-48-mdpi.png
deleted file mode 100644
index e79c606..0000000
Binary files a/bin/templates/project/www/res/icon/android/icon-48-mdpi.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/res/icon/android/icon-72-hdpi.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/res/icon/android/icon-72-hdpi.png b/bin/templates/project/www/res/icon/android/icon-72-hdpi.png
deleted file mode 100644
index 4d27634..0000000
Binary files a/bin/templates/project/www/res/icon/android/icon-72-hdpi.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/res/icon/android/icon-96-xhdpi.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/res/icon/android/icon-96-xhdpi.png b/bin/templates/project/www/res/icon/android/icon-96-xhdpi.png
deleted file mode 100644
index ec7ffbf..0000000
Binary files a/bin/templates/project/www/res/icon/android/icon-96-xhdpi.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/res/icon/bada-wac/icon-48-type5.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/res/icon/bada-wac/icon-48-type5.png b/bin/templates/project/www/res/icon/bada-wac/icon-48-type5.png
deleted file mode 100644
index 8ad8bac..0000000
Binary files a/bin/templates/project/www/res/icon/bada-wac/icon-48-type5.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/res/icon/bada-wac/icon-50-type3.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/res/icon/bada-wac/icon-50-type3.png b/bin/templates/project/www/res/icon/bada-wac/icon-50-type3.png
deleted file mode 100644
index c6ddf84..0000000
Binary files a/bin/templates/project/www/res/icon/bada-wac/icon-50-type3.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/res/icon/bada-wac/icon-80-type4.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/res/icon/bada-wac/icon-80-type4.png b/bin/templates/project/www/res/icon/bada-wac/icon-80-type4.png
deleted file mode 100644
index f86a27a..0000000
Binary files a/bin/templates/project/www/res/icon/bada-wac/icon-80-type4.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/res/icon/bada/icon-128.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/res/icon/bada/icon-128.png b/bin/templates/project/www/res/icon/bada/icon-128.png
deleted file mode 100644
index 3516df3..0000000
Binary files a/bin/templates/project/www/res/icon/bada/icon-128.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/res/icon/blackberry/icon-80.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/res/icon/blackberry/icon-80.png b/bin/templates/project/www/res/icon/blackberry/icon-80.png
deleted file mode 100644
index f86a27a..0000000
Binary files a/bin/templates/project/www/res/icon/blackberry/icon-80.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/res/icon/blackberry10/icon-80.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/res/icon/blackberry10/icon-80.png b/bin/templates/project/www/res/icon/blackberry10/icon-80.png
deleted file mode 100644
index f86a27a..0000000
Binary files a/bin/templates/project/www/res/icon/blackberry10/icon-80.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/res/icon/ios/icon-57-2x.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/res/icon/ios/icon-57-2x.png b/bin/templates/project/www/res/icon/ios/icon-57-2x.png
deleted file mode 100644
index efd9c37..0000000
Binary files a/bin/templates/project/www/res/icon/ios/icon-57-2x.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/res/icon/ios/icon-57.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/res/icon/ios/icon-57.png b/bin/templates/project/www/res/icon/ios/icon-57.png
deleted file mode 100644
index c795fc4..0000000
Binary files a/bin/templates/project/www/res/icon/ios/icon-57.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/res/icon/ios/icon-72-2x.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/res/icon/ios/icon-72-2x.png b/bin/templates/project/www/res/icon/ios/icon-72-2x.png
deleted file mode 100644
index dd819da..0000000
Binary files a/bin/templates/project/www/res/icon/ios/icon-72-2x.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/res/icon/ios/icon-72.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/res/icon/ios/icon-72.png b/bin/templates/project/www/res/icon/ios/icon-72.png
deleted file mode 100644
index b1cfde7..0000000
Binary files a/bin/templates/project/www/res/icon/ios/icon-72.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/res/icon/tizen/icon-128.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/res/icon/tizen/icon-128.png b/bin/templates/project/www/res/icon/tizen/icon-128.png
deleted file mode 100644
index 3516df3..0000000
Binary files a/bin/templates/project/www/res/icon/tizen/icon-128.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/res/icon/webos/icon-64.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/res/icon/webos/icon-64.png b/bin/templates/project/www/res/icon/webos/icon-64.png
deleted file mode 100644
index 03b3849..0000000
Binary files a/bin/templates/project/www/res/icon/webos/icon-64.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/res/icon/windows-phone/icon-173-tile.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/res/icon/windows-phone/icon-173-tile.png b/bin/templates/project/www/res/icon/windows-phone/icon-173-tile.png
deleted file mode 100644
index 4f15e20..0000000
Binary files a/bin/templates/project/www/res/icon/windows-phone/icon-173-tile.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/res/icon/windows-phone/icon-48.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/res/icon/windows-phone/icon-48.png b/bin/templates/project/www/res/icon/windows-phone/icon-48.png
deleted file mode 100644
index 8ad8bac..0000000
Binary files a/bin/templates/project/www/res/icon/windows-phone/icon-48.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/bin/templates/project/www/res/icon/windows-phone/icon-62-tile.png
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/res/icon/windows-phone/icon-62-tile.png b/bin/templates/project/www/res/icon/windows-phone/icon-62-tile.png
deleted file mode 100644
index aab6061..0000000
Binary files a/bin/templates/project/www/res/icon/windows-phone/icon-62-tile.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3b4a52f6/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 8a2b4ed..76b3f70 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,8 @@
"name": "cordova-browser",
"version": "4.2.0-dev",
"description": "cordova-browser release",
- "main": "bin/create",
+ "main": "bin/template/cordova/Api.js",
+ "bin": "bin/create",
"repository": {
"type": "git",
"url": "https://git-wip-us.apache.org/repos/asf/cordova-browser.git"
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[23/25] cordova-browser git commit: remove excessive console logging
Posted by pu...@apache.org.
remove excessive console logging
Project: http://git-wip-us.apache.org/repos/asf/cordova-browser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-browser/commit/adfd7874
Tree: http://git-wip-us.apache.org/repos/asf/cordova-browser/tree/adfd7874
Diff: http://git-wip-us.apache.org/repos/asf/cordova-browser/diff/adfd7874
Branch: refs/heads/master
Commit: adfd78743ed616be955e4dfee3175de3c26d3961
Parents: 9a341aa
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu May 25 13:22:48 2017 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu May 25 13:22:48 2017 -0700
----------------------------------------------------------------------
bin/lib/create.js | 5 -
node_modules/q/CHANGES.md | 786 ---------------
node_modules/q/LICENSE | 18 -
node_modules/q/README.md | 881 ----------------
node_modules/q/package.json | 120 ---
node_modules/q/q.js | 2048 --------------------------------------
node_modules/q/queue.js | 35 -
7 files changed, 3893 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/adfd7874/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/bin/lib/create.js b/bin/lib/create.js
index 33a31a1..805c48c 100644
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -27,11 +27,6 @@ var fs = require('fs'),
check_reqs = require('./check_reqs');
module.exports.createProject = function(project_path,package_name,project_name){
-
- console.log("ROOT = " + ROOT);
- console.log("browser :: createProject",project_path,package_name,project_name);
-
-
/*
// create the dest and the standard place for our api to live
// platforms/platformName/cordova/Api.js
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/adfd7874/node_modules/q/CHANGES.md
----------------------------------------------------------------------
diff --git a/node_modules/q/CHANGES.md b/node_modules/q/CHANGES.md
deleted file mode 100644
index cd351fd..0000000
--- a/node_modules/q/CHANGES.md
+++ /dev/null
@@ -1,786 +0,0 @@
-
-## 1.4.1
-
- - Address an issue that prevented Q from being used as a `<script>` for
- Firefox add-ons. Q can now be used in any environment that provides `window`
- or `self` globals, favoring `window` since add-ons have an an immutable
- `self` that is distinct from `window`.
-
-## 1.4.0
-
- - Add `noConflict` support for use in `<script>` (@jahnjw).
-
-## 1.3.0
-
- - Add tracking for unhandled and handled rejections in Node.js (@benjamingr).
-
-## 1.2.1
-
- - Fix Node.js environment detection for modern Browserify (@kahnjw).
-
-## 1.2.0
-
- - Added Q.any(promisesArray) method (@vergara).
- Returns a promise fulfilled with the value of the first resolved promise in
- promisesArray. If all promises in promisesArray are rejected, it returns
- a rejected promise.
-
-## 1.1.2
-
- - Removed extraneous files from the npm package by using the "files"
- whitelist in package.json instead of the .npmignore blacklist.
- (@anton-rudeshko)
-
-## 1.1.1
-
- - Fix a pair of regressions in bootstrapping, one which precluded
- WebWorker support, and another that precluded support in
- ``<script>`` usage outright. #607
-
-## 1.1.0
-
- - Adds support for enabling long stack traces in node.js by setting
- environment variable `Q_DEBUG=1`.
- - Introduces the `tap` method to promises, which will see a value
- pass through without alteration.
- - Use instanceof to recognize own promise instances as opposed to
- thenables.
- - Construct timeout errors with `code === ETIMEDOUT` (Kornel Lesiński)
- - More descriminant CommonJS module environment detection.
- - Dropped continuous integration for Node.js 0.6 and 0.8 because of
- changes to npm that preclude the use of new `^` version predicate
- operator in any transitive dependency.
- - Users can now override `Q.nextTick`.
-
-## 1.0.1
-
- - Adds support for `Q.Promise`, which implements common usage of the
- ES6 `Promise` constructor and its methods. `Promise` does not have
- a valid promise constructor and a proper implementation awaits
- version 2 of Q.
- - Removes the console stopgap for a promise inspector. This no longer
- works with any degree of reliability.
- - Fixes support for content security policies that forbid eval. Now
- using the `StopIteration` global to distinguish SpiderMonkey
- generators from ES6 generators, assuming that they will never
- coexist.
-
-## 1.0.0
-
-:cake: This is all but a re-release of version 0.9, which has settled
-into a gentle maintenance mode and rightly deserves an official 1.0.
-An ambitious 2.0 release is already around the corner, but 0.9/1.0
-have been distributed far and wide and demand long term support.
-
- - Q will now attempt to post a debug message in browsers regardless
- of whether window.Touch is defined. Chrome at least now has this
- property regardless of whether touch is supported by the underlying
- hardware.
- - Remove deprecation warning from `promise.valueOf`. The function is
- called by the browser in various ways so there is no way to
- distinguish usage that should be migrated from usage that cannot be
- altered.
-
-## 0.9.7
-
- - :warning: `q.min.js` is no longer checked-in. It is however still
- created by Grunt and NPM.
- - Fixes a bug that inhibited `Q.async` with implementations of the new
- ES6 generators.
- - Fixes a bug with `nextTick` affecting Safari 6.0.5 the first time a
- page loads when an `iframe` is involved.
- - Introduces `passByCopy`, `join`, and `race`.
- - Shows stack traces or error messages on the console, instead of
- `Error` objects.
- - Elimintates wrapper methods for improved performance.
- - `Q.all` now propagates progress notifications of the form you might
- expect of ES6 iterations, `{value, index}` where the `value` is the
- progress notification from the promise at `index`.
-
-## 0.9.6
-
- - Fixes a bug in recognizing the difference between compatible Q
- promises, and Q promises from before the implementation of "inspect".
- The latter are now coerced.
- - Fixes an infinite asynchronous coercion cycle introduced by former
- solution, in two independently sufficient ways. 1.) All promises
- returned by makePromise now implement "inspect", albeit a default
- that reports that the promise has an "unknown" state. 2.) The
- implementation of "then/when" is now in "then" instead of "when", so
- that the responsibility to "coerce" the given promise rests solely in
- the "when" method and the "then" method may assume that "this" is a
- promise of the right type.
- - Refactors `nextTick` to use an unrolled microtask within Q regardless
- of how new ticks a requested. #316 @rkatic
-
-## 0.9.5
-
- - Introduces `inspect` for getting the state of a promise as
- `{state: "fulfilled" | "rejected" | "pending", value | reason}`.
- - Introduces `allSettled` which produces an array of promises states
- for the input promises once they have all "settled". This is in
- accordance with a discussion on Promises/A+ that "settled" refers to
- a promise that is "fulfilled" or "rejected". "resolved" refers to a
- deferred promise that has been "resolved" to another promise,
- "sealing its fate" to the fate of the successor promise.
- - Long stack traces are now off by default. Set `Q.longStackSupport`
- to true to enable long stack traces.
- - Long stack traces can now follow the entire asynchronous history of a
- promise, not just a single jump.
- - Introduces `spawn` for an immediately invoked asychronous generator.
- @jlongster
- - Support for *experimental* synonyms `mapply`, `mcall`, `nmapply`,
- `nmcall` for method invocation.
-
-## 0.9.4
-
- - `isPromise` and `isPromiseAlike` now always returns a boolean
- (even for falsy values). #284 @lfac-pt
- - Support for ES6 Generators in `async` #288 @andywingo
- - Clear duplicate promise rejections from dispatch methods #238 @SLaks
- - Unhandled rejection API #296 @domenic
- `stopUnhandledRejectionTracking`, `getUnhandledReasons`,
- `resetUnhandledRejections`.
-
-## 0.9.3
-
- - Add the ability to give `Q.timeout`'s errors a custom error message. #270
- @jgrenon
- - Fix Q's call-stack busting behavior in Node.js 0.10, by switching from
- `process.nextTick` to `setImmediate`. #254 #259
- - Fix Q's behavior when used with the Mocha test runner in the browser, since
- Mocha introduces a fake `process` global without a `nextTick` property. #267
- - Fix some, but not all, cases wherein Q would give false positives in its
- unhandled rejection detection (#252). A fix for other cases (#238) is
- hopefully coming soon.
- - Made `Q.promise` throw early if given a non-function.
-
-## 0.9.2
-
- - Pass through progress notifications when using `timeout`. #229 @omares
- - Pass through progress notifications when using `delay`.
- - Fix `nbind` to actually bind the `thisArg`. #232 @davidpadbury
-
-## 0.9.1
-
- - Made the AMD detection compatible with the RequireJS optimizer's `namespace`
- option. #225 @terinjokes
- - Fix side effects from `valueOf`, and thus from `isFulfilled`, `isRejected`,
- and `isPending`. #226 @benjamn
-
-## 0.9.0
-
-This release removes many layers of deprecated methods and brings Q closer to
-alignment with Mark Miller’s TC39 [strawman][] for concurrency. At the same
-time, it fixes many bugs and adds a few features around error handling. Finally,
-it comes with an updated and comprehensive [API Reference][].
-
-[strawman]: http://wiki.ecmascript.org/doku.php?id=strawman:concurrency
-[API Reference]: https://github.com/kriskowal/q/wiki/API-Reference
-
-### API Cleanup
-
-The following deprecated or undocumented methods have been removed.
-Their replacements are listed here:
-
-<table>
- <thead>
- <tr>
- <th>0.8.x method</th>
- <th>0.9 replacement</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>Q.ref</code></td>
- <td><code>Q</code></td>
- </tr>
- <tr>
- <td><code>call</code>, <code>apply</code>, <code>bind</code> (*)</td>
- <td><code>fcall</code>/<code>invoke</code>, <code>fapply</code>/<code>post</code>, <code>fbind</code></td>
- </tr>
- <tr>
- <td><code>ncall</code>, <code>napply</code> (*)</td>
- <td><code>nfcall</code>/<code>ninvoke</code>, <code>nfapply</code>/<code>npost</code></td>
- </tr>
- <tr>
- <td><code>end</code></td>
- <td><code>done</code></td>
- </tr>
- <tr>
- <td><code>put</code></td>
- <td><code>set</code></td>
- </tr>
- <tr>
- <td><code>node</code></td>
- <td><code>nbind</code></td>
- </tr>
- <tr>
- <td><code>nend</code></td>
- <td><code>nodeify</code></td>
- </tr>
- <tr>
- <td><code>isResolved</code></td>
- <td><code>isPending</code></td>
- </tr>
- <tr>
- <td><code>deferred.node</code></td>
- <td><code>deferred.makeNodeResolver</code></td>
- </tr>
- <tr>
- <td><code>Method</code>, <code>sender</code></td>
- <td><code>dispatcher</code></td>
- </tr>
- <tr>
- <td><code>send</code></td>
- <td><code>dispatch</code></td>
- </tr>
- <tr>
- <td><code>view</code>, <code>viewInfo</code></td>
- <td>(none)</td>
- </tr>
- </tbody>
-</table>
-
-
-(*) Use of ``thisp`` is discouraged. For calling methods, use ``post`` or
-``invoke``.
-
-### Alignment with the Concurrency Strawman
-
-- Q now exports a `Q(value)` function, an alias for `resolve`.
- `Q.call`, `Q.apply`, and `Q.bind` were removed to make room for the
- same methods on the function prototype.
-- `invoke` has been aliased to `send` in all its forms.
-- `post` with no method name acts like `fapply`.
-
-### Error Handling
-
-- Long stack traces can be turned off by setting `Q.stackJumpLimit` to zero.
- In the future, this property will be used to fine tune how many stack jumps
- are retained in long stack traces; for now, anything nonzero is treated as
- one (since Q only tracks one stack jump at the moment, see #144). #168
-- In Node.js, if there are unhandled rejections when the process exits, they
- are output to the console. #115
-
-### Other
-
-- `delete` and `set` (née `put`) no longer have a fulfillment value.
-- Q promises are no longer frozen, which
- [helps with performance](http://code.google.com/p/v8/issues/detail?id=1858).
-- `thenReject` is now included, as a counterpart to `thenResolve`.
-- The included browser `nextTick` shim is now faster. #195 @rkatic.
-
-### Bug Fixes
-
-- Q now works in Internet Explorer 10. #186 @ForbesLindesay
-- `fbind` no longer hard-binds the returned function's `this` to `undefined`.
- #202
-- `Q.reject` no longer leaks memory. #148
-- `npost` with no arguments now works. #207
-- `allResolved` now works with non-Q promises ("thenables"). #179
-- `keys` behavior is now correct even in browsers without native
- `Object.keys`. #192 @rkatic
-- `isRejected` and the `exception` property now work correctly if the
- rejection reason is falsy. #198
-
-### Internals and Advanced
-
-- The internal interface for a promise now uses
- `dispatchPromise(resolve, op, operands)` instead of `sendPromise(op,
- resolve, ...operands)`, which reduces the cases where Q needs to do
- argument slicing.
-- The internal protocol uses different operands. "put" is now "set".
- "del" is now "delete". "view" and "viewInfo" have been removed.
-- `Q.fulfill` has been added. It is distinct from `Q.resolve` in that
- it does not pass promises through, nor coerces promises from other
- systems. The promise becomes the fulfillment value. This is only
- recommended for use when trying to fulfill a promise with an object that has
- a `then` function that is at the same time not a promise.
-
-## 0.8.12
-- Treat foreign promises as unresolved in `Q.isFulfilled`; this lets `Q.all`
- work on arrays containing foreign promises. #154
-- Fix minor incompliances with the [Promises/A+ spec][] and [test suite][]. #157
- #158
-
-[Promises/A+ spec]: http://promises-aplus.github.com/promises-spec/
-[test suite]: https://github.com/promises-aplus/promises-tests
-
-## 0.8.11
-
- - Added ``nfcall``, ``nfapply``, and ``nfbind`` as ``thisp``-less versions of
- ``ncall``, ``napply``, and ``nbind``. The latter are now deprecated. #142
- - Long stack traces no longer cause linearly-growing memory usage when chaining
- promises together. #111
- - Inspecting ``error.stack`` in a rejection handler will now give a long stack
- trace. #103
- - Fixed ``Q.timeout`` to clear its timeout handle when the promise is rejected;
- previously, it kept the event loop alive until the timeout period expired.
- #145 @dfilatov
- - Added `q/queue` module, which exports an infinite promise queue
- constructor.
-
-## 0.8.10
-
- - Added ``done`` as a replacement for ``end``, taking the usual fulfillment,
- rejection, and progress handlers. It's essentially equivalent to
- ``then(f, r, p).end()``.
- - Added ``Q.onerror``, a settable error trap that you can use to get full stack
- traces for uncaught errors. #94
- - Added ``thenResolve`` as a shortcut for returning a constant value once a
- promise is fulfilled. #108 @ForbesLindesay
- - Various tweaks to progress notification, including propagation and
- transformation of progress values and only forwarding a single progress
- object.
- - Renamed ``nend`` to ``nodeify``. It no longer returns an always-fulfilled
- promise when a Node callback is passed.
- - ``deferred.resolve`` and ``deferred.reject`` no longer (sometimes) return
- ``deferred.promise``.
- - Fixed stack traces getting mangled if they hit ``end`` twice. #116 #121 @ef4
- - Fixed ``ninvoke`` and ``npost`` to work on promises for objects with Node
- methods. #134
- - Fixed accidental coercion of objects with nontrivial ``valueOf`` methods,
- like ``Date``s, by the promise's ``valueOf`` method. #135
- - Fixed ``spread`` not calling the passed rejection handler if given a rejected
- promise.
-
-## 0.8.9
-
- - Added ``nend``
- - Added preliminary progress notification support, via
- ``promise.then(onFulfilled, onRejected, onProgress)``,
- ``promise.progress(onProgress)``, and ``deferred.notify(...progressData)``.
- - Made ``put`` and ``del`` return the object acted upon for easier chaining.
- #84
- - Fixed coercion cycles with cooperating promises. #106
-
-## 0.8.7
-
- - Support [Montage Require](http://github.com/kriskowal/mr)
-
-## 0.8.6
-
- - Fixed ``npost`` and ``ninvoke`` to pass the correct ``thisp``. #74
- - Fixed various cases involving unorthodox rejection reasons. #73 #90
- @ef4
- - Fixed double-resolving of misbehaved custom promises. #75
- - Sped up ``Q.all`` for arrays contain already-resolved promises or scalar
- values. @ForbesLindesay
- - Made stack trace filtering work when concatenating assets. #93 @ef4
- - Added warnings for deprecated methods. @ForbesLindesay
- - Added ``.npmignore`` file so that dependent packages get a slimmer
- ``node_modules`` directory.
-
-## 0.8.5
-
- - Added preliminary support for long traces (@domenic)
- - Added ``fapply``, ``fcall``, ``fbind`` for non-thisp
- promised function calls.
- - Added ``return`` for async generators, where generators
- are implemented.
- - Rejected promises now have an "exception" property. If an object
- isRejected(object), then object.valueOf().exception will
- be the wrapped error.
- - Added Jasmine specifications
- - Support Internet Explorers 7–9 (with multiple bug fixes @domenic)
- - Support Firefox 12
- - Support Safari 5.1.5
- - Support Chrome 18
-
-## 0.8.4
-
- - WARNING: ``promise.timeout`` is now rejected with an ``Error`` object
- and the message now includes the duration of the timeout in
- miliseconds. This doesn't constitute (in my opinion) a
- backward-incompatibility since it is a change of an undocumented and
- unspecified public behavior, but if you happened to depend on the
- exception being a string, you will need to revise your code.
- - Added ``deferred.makeNodeResolver()`` to replace the more cryptic
- ``deferred.node()`` method.
- - Added experimental ``Q.promise(maker(resolve, reject))`` to make a
- promise inside a callback, such that thrown exceptions in the
- callback are converted and the resolver and rejecter are arguments.
- This is a shorthand for making a deferred directly and inspired by
- @gozala’s stream constructor pattern and the Microsoft Windows Metro
- Promise constructor interface.
- - Added experimental ``Q.begin()`` that is intended to kick off chains
- of ``.then`` so that each of these can be reordered without having to
- edit the new and former first step.
-
-## 0.8.3
-
- - Added ``isFulfilled``, ``isRejected``, and ``isResolved``
- to the promise prototype.
- - Added ``allResolved`` for waiting for every promise to either be
- fulfilled or rejected, without propagating an error. @utvara #53
- - Added ``Q.bind`` as a method to transform functions that
- return and throw into promise-returning functions. See
- [an example](https://gist.github.com/1782808). @domenic
- - Renamed ``node`` export to ``nbind``, and added ``napply`` to
- complete the set. ``node`` remains as deprecated. @domenic #58
- - Renamed ``Method`` export to ``sender``. ``Method``
- remains as deprecated and will be removed in the next
- major version since I expect it has very little usage.
- - Added browser console message indicating a live list of
- unhandled errors.
- - Added support for ``msSetImmediate`` (IE10) or ``setImmediate``
- (available via [polyfill](https://github.com/NobleJS/setImmediate))
- as a browser-side ``nextTick`` implementation. #44 #50 #59
- - Stopped using the event-queue dependency, which was in place for
- Narwhal support: now directly using ``process.nextTick``.
- - WARNING: EXPERIMENTAL: added ``finally`` alias for ``fin``, ``catch``
- alias for ``fail``, ``try`` alias for ``call``, and ``delete`` alias
- for ``del``. These properties are enquoted in the library for
- cross-browser compatibility, but may be used as property names in
- modern engines.
-
-## 0.8.2
-
- - Deprecated ``ref`` in favor of ``resolve`` as recommended by
- @domenic.
- - Update event-queue dependency.
-
-## 0.8.1
-
- - Fixed Opera bug. #35 @cadorn
- - Fixed ``Q.all([])`` #32 @domenic
-
-## 0.8.0
-
- - WARNING: ``enqueue`` removed. Use ``nextTick`` instead.
- This is more consistent with NodeJS and (subjectively)
- more explicit and intuitive.
- - WARNING: ``def`` removed. Use ``master`` instead. The
- term ``def`` was too confusing to new users.
- - WARNING: ``spy`` removed in favor of ``fin``.
- - WARNING: ``wait`` removed. Do ``all(args).get(0)`` instead.
- - WARNING: ``join`` removed. Do ``all(args).spread(callback)`` instead.
- - WARNING: Removed the ``Q`` function module.exports alias
- for ``Q.ref``. It conflicts with ``Q.apply`` in weird
- ways, making it uncallable.
- - Revised ``delay`` so that it accepts both ``(value,
- timeout)`` and ``(timeout)`` variations based on
- arguments length.
- - Added ``ref().spread(cb(...args))``, a variant of
- ``then`` that spreads an array across multiple arguments.
- Useful with ``all()``.
- - Added ``defer().node()`` Node callback generator. The
- callback accepts ``(error, value)`` or ``(error,
- ...values)``. For multiple value arguments, the
- fulfillment value is an array, useful in conjunction with
- ``spread``.
- - Added ``node`` and ``ncall``, both with the signature
- ``(fun, thisp_opt, ...args)``. The former is a decorator
- and the latter calls immediately. ``node`` optional
- binds and partially applies. ``ncall`` can bind and pass
- arguments.
-
-## 0.7.2
-
- - Fixed thenable promise assimilation.
-
-## 0.7.1
-
- - Stopped shimming ``Array.prototype.reduce``. The
- enumerable property has bad side-effects. Libraries that
- depend on this (for example, QQ) will need to be revised.
-
-## 0.7.0 - BACKWARD INCOMPATIBILITY
-
- - WARNING: Removed ``report`` and ``asap``
- - WARNING: The ``callback`` argument of the ``fin``
- function no longer receives any arguments. Thus, it can
- be used to call functions that should not receive
- arguments on resolution. Use ``when``, ``then``, or
- ``fail`` if you need a value.
- - IMPORTANT: Fixed a bug in the use of ``MessageChannel``
- for ``nextTick``.
- - Renamed ``enqueue`` to ``nextTick``.
- - Added experimental ``view`` and ``viewInfo`` for creating
- views of promises either when or before they're
- fulfilled.
- - Shims are now externally applied so subsequent scripts or
- dependees can use them.
- - Improved minification results.
- - Improved readability.
-
-## 0.6.0 - BACKWARD INCOMPATIBILITY
-
- - WARNING: In practice, the implementation of ``spy`` and
- the name ``fin`` were useful. I've removed the old
- ``fin`` implementation and renamed/aliased ``spy``.
- - The "q" module now exports its ``ref`` function as a "Q"
- constructor, with module systems that support exports
- assignment including NodeJS, RequireJS, and when used as
- a ``<script>`` tag. Notably, strictly compliant CommonJS
- does not support this, but UncommonJS does.
- - Added ``async`` decorator for generators that use yield
- to "trampoline" promises. In engines that support
- generators (SpiderMonkey), this will greatly reduce the
- need for nested callbacks.
- - Made ``when`` chainable.
- - Made ``all`` chainable.
-
-## 0.5.3
-
- - Added ``all`` and refactored ``join`` and ``wait`` to use
- it. All of these will now reject at the earliest
- rejection.
-
-## 0.5.2
-
- - Minor improvement to ``spy``; now waits for resolution of
- callback promise.
-
-## 0.5.1
-
- - Made most Q API methods chainable on promise objects, and
- turned the previous promise-methods of ``join``,
- ``wait``, and ``report`` into Q API methods.
- - Added ``apply`` and ``call`` to the Q API, and ``apply``
- as a promise handler.
- - Added ``fail``, ``fin``, and ``spy`` to Q and the promise
- prototype for convenience when observing rejection,
- fulfillment and rejection, or just observing without
- affecting the resolution.
- - Renamed ``def`` (although ``def`` remains shimmed until
- the next major release) to ``master``.
- - Switched to using ``MessageChannel`` for next tick task
- enqueue in browsers that support it.
-
-## 0.5.0 - MINOR BACKWARD INCOMPATIBILITY
-
- - Exceptions are no longer reported when consumed.
- - Removed ``error`` from the API. Since exceptions are
- getting consumed, throwing them in an errback causes the
- exception to silently disappear. Use ``end``.
- - Added ``end`` as both an API method and a promise-chain
- ending method. It causes propagated rejections to be
- thrown, which allows Node to write stack traces and
- emit ``uncaughtException`` events, and browsers to
- likewise emit ``onerror`` and log to the console.
- - Added ``join`` and ``wait`` as promise chain functions,
- so you can wait for variadic promises, returning your own
- promise back, or join variadic promises, resolving with a
- callback that receives variadic fulfillment values.
-
-## 0.4.4
-
- - ``end`` no longer returns a promise. It is the end of the
- promise chain.
- - Stopped reporting thrown exceptions in ``when`` callbacks
- and errbacks. These must be explicitly reported through
- ``.end()``, ``.then(null, Q.error)``, or some other
- mechanism.
- - Added ``report`` as an API method, which can be used as
- an errback to report and propagate an error.
- - Added ``report`` as a promise-chain method, so an error
- can be reported if it passes such a gate.
-
-## 0.4.3
-
- - Fixed ``<script>`` support that regressed with 0.4.2
- because of "use strict" in the module system
- multi-plexer.
-
-## 0.4.2
-
- - Added support for RequireJS (jburke)
-
-## 0.4.1
-
- - Added an "end" method to the promise prototype,
- as a shorthand for waiting for the promise to
- be resolved gracefully, and failing to do so,
- to dump an error message.
-
-## 0.4.0 - BACKWARD INCOMPATIBLE*
-
- - *Removed the utility modules. NPM and Node no longer
- expose any module except the main module. These have
- been moved and merged into the "qq" package.
- - *In a non-CommonJS browser, q.js can be used as a script.
- It now creates a Q global variable.
- - Fixed thenable assimilation.
- - Fixed some issues with asap, when it resolves to
- undefined, or throws an exception.
-
-## 0.3.0 - BACKWARD-INCOMPATIBLE
-
- - The `post` method has been reverted to its original
- signature, as provided in Tyler Close's `ref_send` API.
- That is, `post` accepts two arguments, the second of
- which is an arbitrary object, but usually invocation
- arguments as an `Array`. To provide variadic arguments
- to `post`, there is a new `invoke` function that posts
- the variadic arguments to the value given in the first
- argument.
- - The `defined` method has been moved from `q` to `q/util`
- since it gets no use in practice but is still
- theoretically useful.
- - The `Promise` constructor has been renamed to
- `makePromise` to be consistent with the convention that
- functions that do not require the `new` keyword to be
- used as constructors have camelCase names.
- - The `isResolved` function has been renamed to
- `isFulfilled`. There is a new `isResolved` function that
- indicates whether a value is not a promise or, if it is a
- promise, whether it has been either fulfilled or
- rejected. The code has been revised to reflect this
- nuance in terminology.
-
-## 0.2.10
-
- - Added `join` to `"q/util"` for variadically joining
- multiple promises.
-
-## 0.2.9
-
- - The future-compatible `invoke` method has been added,
- to replace `post`, since `post` will become backward-
- incompatible in the next major release.
- - Exceptions thrown in the callbacks of a `when` call are
- now emitted to Node's `"uncaughtException"` `process`
- event in addition to being returned as a rejection reason.
-
-## 0.2.8
-
- - Exceptions thrown in the callbacks of a `when` call
- are now consumed, warned, and transformed into
- rejections of the promise returned by `when`.
-
-## 0.2.7
-
- - Fixed a minor bug in thenable assimilation, regressed
- because of the change in the forwarding protocol.
- - Fixed behavior of "q/util" `deep` method on dates and
- other primitives. Github issue #11.
-
-## 0.2.6
-
- - Thenables (objects with a "then" method) are accepted
- and provided, bringing this implementation of Q
- into conformance with Promises/A, B, and D.
- - Added `makePromise`, to replace the `Promise` function
- eventually.
- - Rejections are now also duck-typed. A rejection is a
- promise with a valueOf method that returns a rejection
- descriptor. A rejection descriptor has a
- "promiseRejected" property equal to "true" and a
- "reason" property corresponding to the rejection reason.
- - Altered the `makePromise` API such that the `fallback`
- method no longer receives a superfluous `resolved` method
- after the `operator`. The fallback method is responsible
- only for returning a resolution. This breaks an
- undocumented API, so third-party API's depending on the
- previous undocumented behavior may break.
-
-## 0.2.5
-
- - Changed promises into a duck-type such that multiple
- instances of the Q module can exchange promise objects.
- A promise is now defined as "an object that implements the
- `promiseSend(op, resolved, ...)` method and `valueOf`".
- - Exceptions in promises are now captured and returned
- as rejections.
-
-## 0.2.4
-
- - Fixed bug in `ref` that prevented `del` messages from
- being received (gozala)
- - Fixed a conflict with FireFox 4; constructor property
- is now read-only.
-
-## 0.2.3
-
- - Added `keys` message to promises and to the promise API.
-
-## 0.2.2
-
- - Added boilerplate to `q/queue` and `q/util`.
- - Fixed missing dependency to `q/queue`.
-
-## 0.2.1
-
- - The `resolve` and `reject` methods of `defer` objects now
- return the resolution promise for convenience.
- - Added `q/util`, which provides `step`, `delay`, `shallow`,
- `deep`, and three reduction orders.
- - Added `q/queue` module for a promise `Queue`.
- - Added `q-comm` to the list of compatible libraries.
- - Deprecated `defined` from `q`, with intent to move it to
- `q/util`.
-
-## 0.2.0 - BACKWARD INCOMPATIBLE
-
- - Changed post(ref, name, args) to variadic
- post(ref, name, ...args). BACKWARD INCOMPATIBLE
- - Added a def(value) method to annotate an object as being
- necessarily a local value that cannot be serialized, such
- that inter-process/worker/vat promise communication
- libraries will send messages to it, but never send it
- back.
- - Added a send(value, op, ...args) method to the public API, for
- forwarding messages to a value or promise in a future turn.
-
-## 0.1.9
-
- - Added isRejected() for testing whether a value is a rejected
- promise. isResolved() retains the behavior of stating
- that rejected promises are not resolved.
-
-## 0.1.8
-
- - Fixed isResolved(null) and isResolved(undefined) [issue #9]
- - Fixed a problem with the Object.create shim
-
-## 0.1.7
-
- - shimmed ES5 Object.create in addition to Object.freeze
- for compatibility on non-ES5 engines (gozala)
-
-## 0.1.6
-
- - Q.isResolved added
- - promise.valueOf() now returns the value of resolved
- and near values
- - asap retried
- - promises are frozen when possible
-
-## 0.1.5
-
- - fixed dependency list for Teleport (gozala)
- - all unit tests now pass (gozala)
-
-## 0.1.4
-
- - added support for Teleport as an engine (gozala)
- - simplified and updated methods for getting internal
- print and enqueue functions universally (gozala)
-
-## 0.1.3
-
- - fixed erroneous link to the q module in package.json
-
-## 0.1.2
-
- - restructured for overlay style package compatibility
-
-## 0.1.0
-
- - removed asap because it was broken, probably down to the
- philosophy.
-
-## 0.0.3
-
- - removed q-util
- - fixed asap so it returns a value if completed
-
-## 0.0.2
-
- - added q-util
-
-## 0.0.1
-
- - initial version
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/adfd7874/node_modules/q/LICENSE
----------------------------------------------------------------------
diff --git a/node_modules/q/LICENSE b/node_modules/q/LICENSE
deleted file mode 100644
index 8a706b5..0000000
--- a/node_modules/q/LICENSE
+++ /dev/null
@@ -1,18 +0,0 @@
-Copyright 2009–2014 Kristopher Michael Kowal. All rights reserved.
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to
-deal in the Software without restriction, including without limitation the
-rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-sell copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-IN THE SOFTWARE.
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/adfd7874/node_modules/q/README.md
----------------------------------------------------------------------
diff --git a/node_modules/q/README.md b/node_modules/q/README.md
deleted file mode 100644
index 9065bfa..0000000
--- a/node_modules/q/README.md
+++ /dev/null
@@ -1,881 +0,0 @@
-[](http://travis-ci.org/kriskowal/q)
-
-<a href="http://promises-aplus.github.com/promises-spec">
- <img src="http://kriskowal.github.io/q/q.png"
- align="right" alt="Q logo" />
-</a>
-
-*This is Q version 1, from the `v1` branch in Git. This documentation applies to
-the latest of both the version 1 and version 0.9 release trains. These releases
-are stable. There will be no further releases of 0.9 after 0.9.7 which is nearly
-equivalent to version 1.0.0. All further releases of `q@~1.0` will be backward
-compatible. The version 2 release train introduces significant and
-backward-incompatible changes and is experimental at this time.*
-
-If a function cannot return a value or throw an exception without
-blocking, it can return a promise instead. A promise is an object
-that represents the return value or the thrown exception that the
-function may eventually provide. A promise can also be used as a
-proxy for a [remote object][Q-Connection] to overcome latency.
-
-[Q-Connection]: https://github.com/kriskowal/q-connection
-
-On the first pass, promises can mitigate the “[Pyramid of
-Doom][POD]”: the situation where code marches to the right faster
-than it marches forward.
-
-[POD]: http://calculist.org/blog/2011/12/14/why-coroutines-wont-work-on-the-web/
-
-```javascript
-step1(function (value1) {
- step2(value1, function(value2) {
- step3(value2, function(value3) {
- step4(value3, function(value4) {
- // Do something with value4
- });
- });
- });
-});
-```
-
-With a promise library, you can flatten the pyramid.
-
-```javascript
-Q.fcall(promisedStep1)
-.then(promisedStep2)
-.then(promisedStep3)
-.then(promisedStep4)
-.then(function (value4) {
- // Do something with value4
-})
-.catch(function (error) {
- // Handle any error from all above steps
-})
-.done();
-```
-
-With this approach, you also get implicit error propagation, just like `try`,
-`catch`, and `finally`. An error in `promisedStep1` will flow all the way to
-the `catch` function, where it’s caught and handled. (Here `promisedStepN` is
-a version of `stepN` that returns a promise.)
-
-The callback approach is called an “inversion of control”.
-A function that accepts a callback instead of a return value
-is saying, “Don’t call me, I’ll call you.”. Promises
-[un-invert][IOC] the inversion, cleanly separating the input
-arguments from control flow arguments. This simplifies the
-use and creation of API’s, particularly variadic,
-rest and spread arguments.
-
-[IOC]: http://www.slideshare.net/domenicdenicola/callbacks-promises-and-coroutines-oh-my-the-evolution-of-asynchronicity-in-javascript
-
-
-## Getting Started
-
-The Q module can be loaded as:
-
-- A ``<script>`` tag (creating a ``Q`` global variable): ~2.5 KB minified and
- gzipped.
-- A Node.js and CommonJS module, available in [npm](https://npmjs.org/) as
- the [q](https://npmjs.org/package/q) package
-- An AMD module
-- A [component](https://github.com/component/component) as ``microjs/q``
-- Using [bower](http://bower.io/) as `q#1.0.1`
-- Using [NuGet](http://nuget.org/) as [Q](https://nuget.org/packages/q)
-
-Q can exchange promises with jQuery, Dojo, When.js, WinJS, and more.
-
-## Resources
-
-Our [wiki][] contains a number of useful resources, including:
-
-- A method-by-method [Q API reference][reference].
-- A growing [examples gallery][examples], showing how Q can be used to make
- everything better. From XHR to database access to accessing the Flickr API,
- Q is there for you.
-- There are many libraries that produce and consume Q promises for everything
- from file system/database access or RPC to templating. For a list of some of
- the more popular ones, see [Libraries][].
-- If you want materials that introduce the promise concept generally, and the
- below tutorial isn't doing it for you, check out our collection of
- [presentations, blog posts, and podcasts][resources].
-- A guide for those [coming from jQuery's `$.Deferred`][jquery].
-
-We'd also love to have you join the Q-Continuum [mailing list][].
-
-[wiki]: https://github.com/kriskowal/q/wiki
-[reference]: https://github.com/kriskowal/q/wiki/API-Reference
-[examples]: https://github.com/kriskowal/q/wiki/Examples-Gallery
-[Libraries]: https://github.com/kriskowal/q/wiki/Libraries
-[resources]: https://github.com/kriskowal/q/wiki/General-Promise-Resources
-[jquery]: https://github.com/kriskowal/q/wiki/Coming-from-jQuery
-[mailing list]: https://groups.google.com/forum/#!forum/q-continuum
-
-
-## Tutorial
-
-Promises have a ``then`` method, which you can use to get the eventual
-return value (fulfillment) or thrown exception (rejection).
-
-```javascript
-promiseMeSomething()
-.then(function (value) {
-}, function (reason) {
-});
-```
-
-If ``promiseMeSomething`` returns a promise that gets fulfilled later
-with a return value, the first function (the fulfillment handler) will be
-called with the value. However, if the ``promiseMeSomething`` function
-gets rejected later by a thrown exception, the second function (the
-rejection handler) will be called with the exception.
-
-Note that resolution of a promise is always asynchronous: that is, the
-fulfillment or rejection handler will always be called in the next turn of the
-event loop (i.e. `process.nextTick` in Node). This gives you a nice
-guarantee when mentally tracing the flow of your code, namely that
-``then`` will always return before either handler is executed.
-
-In this tutorial, we begin with how to consume and work with promises. We'll
-talk about how to create them, and thus create functions like
-`promiseMeSomething` that return promises, [below](#the-beginning).
-
-
-### Propagation
-
-The ``then`` method returns a promise, which in this example, I’m
-assigning to ``outputPromise``.
-
-```javascript
-var outputPromise = getInputPromise()
-.then(function (input) {
-}, function (reason) {
-});
-```
-
-The ``outputPromise`` variable becomes a new promise for the return
-value of either handler. Since a function can only either return a
-value or throw an exception, only one handler will ever be called and it
-will be responsible for resolving ``outputPromise``.
-
-- If you return a value in a handler, ``outputPromise`` will get
- fulfilled.
-
-- If you throw an exception in a handler, ``outputPromise`` will get
- rejected.
-
-- If you return a **promise** in a handler, ``outputPromise`` will
- “become” that promise. Being able to become a new promise is useful
- for managing delays, combining results, or recovering from errors.
-
-If the ``getInputPromise()`` promise gets rejected and you omit the
-rejection handler, the **error** will go to ``outputPromise``:
-
-```javascript
-var outputPromise = getInputPromise()
-.then(function (value) {
-});
-```
-
-If the input promise gets fulfilled and you omit the fulfillment handler, the
-**value** will go to ``outputPromise``:
-
-```javascript
-var outputPromise = getInputPromise()
-.then(null, function (error) {
-});
-```
-
-Q promises provide a ``fail`` shorthand for ``then`` when you are only
-interested in handling the error:
-
-```javascript
-var outputPromise = getInputPromise()
-.fail(function (error) {
-});
-```
-
-If you are writing JavaScript for modern engines only or using
-CoffeeScript, you may use `catch` instead of `fail`.
-
-Promises also have a ``fin`` function that is like a ``finally`` clause.
-The final handler gets called, with no arguments, when the promise
-returned by ``getInputPromise()`` either returns a value or throws an
-error. The value returned or error thrown by ``getInputPromise()``
-passes directly to ``outputPromise`` unless the final handler fails, and
-may be delayed if the final handler returns a promise.
-
-```javascript
-var outputPromise = getInputPromise()
-.fin(function () {
- // close files, database connections, stop servers, conclude tests
-});
-```
-
-- If the handler returns a value, the value is ignored
-- If the handler throws an error, the error passes to ``outputPromise``
-- If the handler returns a promise, ``outputPromise`` gets postponed. The
- eventual value or error has the same effect as an immediate return
- value or thrown error: a value would be ignored, an error would be
- forwarded.
-
-If you are writing JavaScript for modern engines only or using
-CoffeeScript, you may use `finally` instead of `fin`.
-
-### Chaining
-
-There are two ways to chain promises. You can chain promises either
-inside or outside handlers. The next two examples are equivalent.
-
-```javascript
-return getUsername()
-.then(function (username) {
- return getUser(username)
- .then(function (user) {
- // if we get here without an error,
- // the value returned here
- // or the exception thrown here
- // resolves the promise returned
- // by the first line
- })
-});
-```
-
-```javascript
-return getUsername()
-.then(function (username) {
- return getUser(username);
-})
-.then(function (user) {
- // if we get here without an error,
- // the value returned here
- // or the exception thrown here
- // resolves the promise returned
- // by the first line
-});
-```
-
-The only difference is nesting. It’s useful to nest handlers if you
-need to capture multiple input values in your closure.
-
-```javascript
-function authenticate() {
- return getUsername()
- .then(function (username) {
- return getUser(username);
- })
- // chained because we will not need the user name in the next event
- .then(function (user) {
- return getPassword()
- // nested because we need both user and password next
- .then(function (password) {
- if (user.passwordHash !== hash(password)) {
- throw new Error("Can't authenticate");
- }
- });
- });
-}
-```
-
-
-### Combination
-
-You can turn an array of promises into a promise for the whole,
-fulfilled array using ``all``.
-
-```javascript
-return Q.all([
- eventualAdd(2, 2),
- eventualAdd(10, 20)
-]);
-```
-
-If you have a promise for an array, you can use ``spread`` as a
-replacement for ``then``. The ``spread`` function “spreads” the
-values over the arguments of the fulfillment handler. The rejection handler
-will get called at the first sign of failure. That is, whichever of
-the received promises fails first gets handled by the rejection handler.
-
-```javascript
-function eventualAdd(a, b) {
- return Q.spread([a, b], function (a, b) {
- return a + b;
- })
-}
-```
-
-But ``spread`` calls ``all`` initially, so you can skip it in chains.
-
-```javascript
-return getUsername()
-.then(function (username) {
- return [username, getUser(username)];
-})
-.spread(function (username, user) {
-});
-```
-
-The ``all`` function returns a promise for an array of values. When this
-promise is fulfilled, the array contains the fulfillment values of the original
-promises, in the same order as those promises. If one of the given promises
-is rejected, the returned promise is immediately rejected, not waiting for the
-rest of the batch. If you want to wait for all of the promises to either be
-fulfilled or rejected, you can use ``allSettled``.
-
-```javascript
-Q.allSettled(promises)
-.then(function (results) {
- results.forEach(function (result) {
- if (result.state === "fulfilled") {
- var value = result.value;
- } else {
- var reason = result.reason;
- }
- });
-});
-```
-
-The ``any`` function accepts an array of promises and returns a promise that is
-fulfilled by the first given promise to be fulfilled, or rejected if all of the
-given promises are rejected.
-
-```javascript
-Q.any(promises)
-.then(function (first) {
- // Any of the promises was fulfilled.
-}, function (error) {
- // All of the promises were rejected.
-});
-```
-
-### Sequences
-
-If you have a number of promise-producing functions that need
-to be run sequentially, you can of course do so manually:
-
-```javascript
-return foo(initialVal).then(bar).then(baz).then(qux);
-```
-
-However, if you want to run a dynamically constructed sequence of
-functions, you'll want something like this:
-
-```javascript
-var funcs = [foo, bar, baz, qux];
-
-var result = Q(initialVal);
-funcs.forEach(function (f) {
- result = result.then(f);
-});
-return result;
-```
-
-You can make this slightly more compact using `reduce`:
-
-```javascript
-return funcs.reduce(function (soFar, f) {
- return soFar.then(f);
-}, Q(initialVal));
-```
-
-Or, you could use the ultra-compact version:
-
-```javascript
-return funcs.reduce(Q.when, Q(initialVal));
-```
-
-### Handling Errors
-
-One sometimes-unintuive aspect of promises is that if you throw an
-exception in the fulfillment handler, it will not be caught by the error
-handler.
-
-```javascript
-return foo()
-.then(function (value) {
- throw new Error("Can't bar.");
-}, function (error) {
- // We only get here if "foo" fails
-});
-```
-
-To see why this is, consider the parallel between promises and
-``try``/``catch``. We are ``try``-ing to execute ``foo()``: the error
-handler represents a ``catch`` for ``foo()``, while the fulfillment handler
-represents code that happens *after* the ``try``/``catch`` block.
-That code then needs its own ``try``/``catch`` block.
-
-In terms of promises, this means chaining your rejection handler:
-
-```javascript
-return foo()
-.then(function (value) {
- throw new Error("Can't bar.");
-})
-.fail(function (error) {
- // We get here with either foo's error or bar's error
-});
-```
-
-### Progress Notification
-
-It's possible for promises to report their progress, e.g. for tasks that take a
-long time like a file upload. Not all promises will implement progress
-notifications, but for those that do, you can consume the progress values using
-a third parameter to ``then``:
-
-```javascript
-return uploadFile()
-.then(function () {
- // Success uploading the file
-}, function (err) {
- // There was an error, and we get the reason for error
-}, function (progress) {
- // We get notified of the upload's progress as it is executed
-});
-```
-
-Like `fail`, Q also provides a shorthand for progress callbacks
-called `progress`:
-
-```javascript
-return uploadFile().progress(function (progress) {
- // We get notified of the upload's progress
-});
-```
-
-### The End
-
-When you get to the end of a chain of promises, you should either
-return the last promise or end the chain. Since handlers catch
-errors, it’s an unfortunate pattern that the exceptions can go
-unobserved.
-
-So, either return it,
-
-```javascript
-return foo()
-.then(function () {
- return "bar";
-});
-```
-
-Or, end it.
-
-```javascript
-foo()
-.then(function () {
- return "bar";
-})
-.done();
-```
-
-Ending a promise chain makes sure that, if an error doesn’t get
-handled before the end, it will get rethrown and reported.
-
-This is a stopgap. We are exploring ways to make unhandled errors
-visible without any explicit handling.
-
-
-### The Beginning
-
-Everything above assumes you get a promise from somewhere else. This
-is the common case. Every once in a while, you will need to create a
-promise from scratch.
-
-#### Using ``Q.fcall``
-
-You can create a promise from a value using ``Q.fcall``. This returns a
-promise for 10.
-
-```javascript
-return Q.fcall(function () {
- return 10;
-});
-```
-
-You can also use ``fcall`` to get a promise for an exception.
-
-```javascript
-return Q.fcall(function () {
- throw new Error("Can't do it");
-});
-```
-
-As the name implies, ``fcall`` can call functions, or even promised
-functions. This uses the ``eventualAdd`` function above to add two
-numbers.
-
-```javascript
-return Q.fcall(eventualAdd, 2, 2);
-```
-
-
-#### Using Deferreds
-
-If you have to interface with asynchronous functions that are callback-based
-instead of promise-based, Q provides a few shortcuts (like ``Q.nfcall`` and
-friends). But much of the time, the solution will be to use *deferreds*.
-
-```javascript
-var deferred = Q.defer();
-FS.readFile("foo.txt", "utf-8", function (error, text) {
- if (error) {
- deferred.reject(new Error(error));
- } else {
- deferred.resolve(text);
- }
-});
-return deferred.promise;
-```
-
-Note that a deferred can be resolved with a value or a promise. The
-``reject`` function is a shorthand for resolving with a rejected
-promise.
-
-```javascript
-// this:
-deferred.reject(new Error("Can't do it"));
-
-// is shorthand for:
-var rejection = Q.fcall(function () {
- throw new Error("Can't do it");
-});
-deferred.resolve(rejection);
-```
-
-This is a simplified implementation of ``Q.delay``.
-
-```javascript
-function delay(ms) {
- var deferred = Q.defer();
- setTimeout(deferred.resolve, ms);
- return deferred.promise;
-}
-```
-
-This is a simplified implementation of ``Q.timeout``
-
-```javascript
-function timeout(promise, ms) {
- var deferred = Q.defer();
- Q.when(promise, deferred.resolve);
- delay(ms).then(function () {
- deferred.reject(new Error("Timed out"));
- });
- return deferred.promise;
-}
-```
-
-Finally, you can send a progress notification to the promise with
-``deferred.notify``.
-
-For illustration, this is a wrapper for XML HTTP requests in the browser. Note
-that a more [thorough][XHR] implementation would be in order in practice.
-
-[XHR]: https://github.com/montagejs/mr/blob/71e8df99bb4f0584985accd6f2801ef3015b9763/browser.js#L29-L73
-
-```javascript
-function requestOkText(url) {
- var request = new XMLHttpRequest();
- var deferred = Q.defer();
-
- request.open("GET", url, true);
- request.onload = onload;
- request.onerror = onerror;
- request.onprogress = onprogress;
- request.send();
-
- function onload() {
- if (request.status === 200) {
- deferred.resolve(request.responseText);
- } else {
- deferred.reject(new Error("Status code was " + request.status));
- }
- }
-
- function onerror() {
- deferred.reject(new Error("Can't XHR " + JSON.stringify(url)));
- }
-
- function onprogress(event) {
- deferred.notify(event.loaded / event.total);
- }
-
- return deferred.promise;
-}
-```
-
-Below is an example of how to use this ``requestOkText`` function:
-
-```javascript
-requestOkText("http://localhost:3000")
-.then(function (responseText) {
- // If the HTTP response returns 200 OK, log the response text.
- console.log(responseText);
-}, function (error) {
- // If there's an error or a non-200 status code, log the error.
- console.error(error);
-}, function (progress) {
- // Log the progress as it comes in.
- console.log("Request progress: " + Math.round(progress * 100) + "%");
-});
-```
-
-#### Using `Q.Promise`
-
-This is an alternative promise-creation API that has the same power as
-the deferred concept, but without introducing another conceptual entity.
-
-Rewriting the `requestOkText` example above using `Q.Promise`:
-
-```javascript
-function requestOkText(url) {
- return Q.Promise(function(resolve, reject, notify) {
- var request = new XMLHttpRequest();
-
- request.open("GET", url, true);
- request.onload = onload;
- request.onerror = onerror;
- request.onprogress = onprogress;
- request.send();
-
- function onload() {
- if (request.status === 200) {
- resolve(request.responseText);
- } else {
- reject(new Error("Status code was " + request.status));
- }
- }
-
- function onerror() {
- reject(new Error("Can't XHR " + JSON.stringify(url)));
- }
-
- function onprogress(event) {
- notify(event.loaded / event.total);
- }
- });
-}
-```
-
-If `requestOkText` were to throw an exception, the returned promise would be
-rejected with that thrown exception as the rejection reason.
-
-### The Middle
-
-If you are using a function that may return a promise, but just might
-return a value if it doesn’t need to defer, you can use the “static”
-methods of the Q library.
-
-The ``when`` function is the static equivalent for ``then``.
-
-```javascript
-return Q.when(valueOrPromise, function (value) {
-}, function (error) {
-});
-```
-
-All of the other methods on a promise have static analogs with the
-same name.
-
-The following are equivalent:
-
-```javascript
-return Q.all([a, b]);
-```
-
-```javascript
-return Q.fcall(function () {
- return [a, b];
-})
-.all();
-```
-
-When working with promises provided by other libraries, you should
-convert it to a Q promise. Not all promise libraries make the same
-guarantees as Q and certainly don’t provide all of the same methods.
-Most libraries only provide a partially functional ``then`` method.
-This thankfully is all we need to turn them into vibrant Q promises.
-
-```javascript
-return Q($.ajax(...))
-.then(function () {
-});
-```
-
-If there is any chance that the promise you receive is not a Q promise
-as provided by your library, you should wrap it using a Q function.
-You can even use ``Q.invoke`` as a shorthand.
-
-```javascript
-return Q.invoke($, 'ajax', ...)
-.then(function () {
-});
-```
-
-
-### Over the Wire
-
-A promise can serve as a proxy for another object, even a remote
-object. There are methods that allow you to optimistically manipulate
-properties or call functions. All of these interactions return
-promises, so they can be chained.
-
-```
-direct manipulation using a promise as a proxy
--------------------------- -------------------------------
-value.foo promise.get("foo")
-value.foo = value promise.put("foo", value)
-delete value.foo promise.del("foo")
-value.foo(...args) promise.post("foo", [args])
-value.foo(...args) promise.invoke("foo", ...args)
-value(...args) promise.fapply([args])
-value(...args) promise.fcall(...args)
-```
-
-If the promise is a proxy for a remote object, you can shave
-round-trips by using these functions instead of ``then``. To take
-advantage of promises for remote objects, check out [Q-Connection][].
-
-[Q-Connection]: https://github.com/kriskowal/q-connection
-
-Even in the case of non-remote objects, these methods can be used as
-shorthand for particularly-simple fulfillment handlers. For example, you
-can replace
-
-```javascript
-return Q.fcall(function () {
- return [{ foo: "bar" }, { foo: "baz" }];
-})
-.then(function (value) {
- return value[0].foo;
-});
-```
-
-with
-
-```javascript
-return Q.fcall(function () {
- return [{ foo: "bar" }, { foo: "baz" }];
-})
-.get(0)
-.get("foo");
-```
-
-
-### Adapting Node
-
-If you're working with functions that make use of the Node.js callback pattern,
-where callbacks are in the form of `function(err, result)`, Q provides a few
-useful utility functions for converting between them. The most straightforward
-are probably `Q.nfcall` and `Q.nfapply` ("Node function call/apply") for calling
-Node.js-style functions and getting back a promise:
-
-```javascript
-return Q.nfcall(FS.readFile, "foo.txt", "utf-8");
-return Q.nfapply(FS.readFile, ["foo.txt", "utf-8"]);
-```
-
-If you are working with methods, instead of simple functions, you can easily
-run in to the usual problems where passing a method to another function—like
-`Q.nfcall`—"un-binds" the method from its owner. To avoid this, you can either
-use `Function.prototype.bind` or some nice shortcut methods we provide:
-
-```javascript
-return Q.ninvoke(redisClient, "get", "user:1:id");
-return Q.npost(redisClient, "get", ["user:1:id"]);
-```
-
-You can also create reusable wrappers with `Q.denodeify` or `Q.nbind`:
-
-```javascript
-var readFile = Q.denodeify(FS.readFile);
-return readFile("foo.txt", "utf-8");
-
-var redisClientGet = Q.nbind(redisClient.get, redisClient);
-return redisClientGet("user:1:id");
-```
-
-Finally, if you're working with raw deferred objects, there is a
-`makeNodeResolver` method on deferreds that can be handy:
-
-```javascript
-var deferred = Q.defer();
-FS.readFile("foo.txt", "utf-8", deferred.makeNodeResolver());
-return deferred.promise;
-```
-
-### Long Stack Traces
-
-Q comes with optional support for “long stack traces,” wherein the `stack`
-property of `Error` rejection reasons is rewritten to be traced along
-asynchronous jumps instead of stopping at the most recent one. As an example:
-
-```js
-function theDepthsOfMyProgram() {
- Q.delay(100).done(function explode() {
- throw new Error("boo!");
- });
-}
-
-theDepthsOfMyProgram();
-```
-
-usually would give a rather unhelpful stack trace looking something like
-
-```
-Error: boo!
- at explode (/path/to/test.js:3:11)
- at _fulfilled (/path/to/test.js:q:54)
- at resolvedValue.promiseDispatch.done (/path/to/q.js:823:30)
- at makePromise.promise.promiseDispatch (/path/to/q.js:496:13)
- at pending (/path/to/q.js:397:39)
- at process.startup.processNextTick.process._tickCallback (node.js:244:9)
-```
-
-But, if you turn this feature on by setting
-
-```js
-Q.longStackSupport = true;
-```
-
-then the above code gives a nice stack trace to the tune of
-
-```
-Error: boo!
- at explode (/path/to/test.js:3:11)
-From previous event:
- at theDepthsOfMyProgram (/path/to/test.js:2:16)
- at Object.<anonymous> (/path/to/test.js:7:1)
-```
-
-Note how you can see the function that triggered the async operation in the
-stack trace! This is very helpful for debugging, as otherwise you end up getting
-only the first line, plus a bunch of Q internals, with no sign of where the
-operation started.
-
-In node.js, this feature can also be enabled through the Q_DEBUG environment
-variable:
-
-```
-Q_DEBUG=1 node server.js
-```
-
-This will enable long stack support in every instance of Q.
-
-This feature does come with somewhat-serious performance and memory overhead,
-however. If you're working with lots of promises, or trying to scale a server
-to many users, you should probably keep it off. But in development, go for it!
-
-## Tests
-
-You can view the results of the Q test suite [in your browser][tests]!
-
-[tests]: https://rawgithub.com/kriskowal/q/v1/spec/q-spec.html
-
-## License
-
-Copyright 2009–2015 Kristopher Michael Kowal and contributors
-MIT License (enclosed)
-
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/adfd7874/node_modules/q/package.json
----------------------------------------------------------------------
diff --git a/node_modules/q/package.json b/node_modules/q/package.json
deleted file mode 100644
index 6dd257b..0000000
--- a/node_modules/q/package.json
+++ /dev/null
@@ -1,120 +0,0 @@
-{
- "name": "q",
- "version": "1.4.1",
- "description": "A library for promises (CommonJS/Promises/A,B,D)",
- "homepage": "https://github.com/kriskowal/q",
- "author": {
- "name": "Kris Kowal",
- "email": "kris@cixar.com",
- "url": "https://github.com/kriskowal"
- },
- "keywords": [
- "q",
- "promise",
- "promises",
- "promises-a",
- "promises-aplus",
- "deferred",
- "future",
- "async",
- "flow control",
- "fluent",
- "browser",
- "node"
- ],
- "contributors": [
- {
- "name": "Kris Kowal",
- "email": "kris@cixar.com",
- "url": "https://github.com/kriskowal"
- },
- {
- "name": "Irakli Gozalishvili",
- "email": "rfobic@gmail.com",
- "url": "http://jeditoolkit.com"
- },
- {
- "name": "Domenic Denicola",
- "email": "domenic@domenicdenicola.com",
- "url": "http://domenicdenicola.com"
- }
- ],
- "bugs": {
- "url": "http://github.com/kriskowal/q/issues"
- },
- "license": {
- "type": "MIT",
- "url": "http://github.com/kriskowal/q/raw/master/LICENSE"
- },
- "main": "q.js",
- "files": [
- "LICENSE",
- "q.js",
- "queue.js"
- ],
- "repository": {
- "type": "git",
- "url": "git://github.com/kriskowal/q.git"
- },
- "engines": {
- "node": ">=0.6.0",
- "teleport": ">=0.2.0"
- },
- "dependencies": {},
- "devDependencies": {
- "cover": "*",
- "grunt": "~0.4.1",
- "grunt-cli": "~0.1.9",
- "grunt-contrib-uglify": "~0.9.1",
- "jasmine-node": "1.11.0",
- "jshint": "~2.1.9",
- "matcha": "~0.2.0",
- "opener": "*",
- "promises-aplus-tests": "1.x"
- },
- "scripts": {
- "test": "jasmine-node spec && promises-aplus-tests spec/aplus-adapter",
- "test-browser": "opener spec/q-spec.html",
- "benchmark": "matcha",
- "lint": "jshint q.js",
- "cover": "cover run jasmine-node spec && cover report html && opener cover_html/index.html",
- "minify": "grunt",
- "prepublish": "grunt"
- },
- "overlay": {
- "teleport": {
- "dependencies": {
- "system": ">=0.0.4"
- }
- }
- },
- "directories": {
- "test": "./spec"
- },
- "gitHead": "d373079d3620152e3d60e82f27265a09ee0e81bd",
- "_id": "q@1.4.1",
- "_shasum": "55705bcd93c5f3673530c2c2cbc0c2b3addc286e",
- "_from": "q@>=1.4.1 <2.0.0",
- "_npmVersion": "2.8.3",
- "_nodeVersion": "1.8.1",
- "_npmUser": {
- "name": "kriskowal",
- "email": "kris.kowal@cixar.com"
- },
- "maintainers": [
- {
- "name": "kriskowal",
- "email": "kris.kowal@cixar.com"
- },
- {
- "name": "domenic",
- "email": "domenic@domenicdenicola.com"
- }
- ],
- "dist": {
- "shasum": "55705bcd93c5f3673530c2c2cbc0c2b3addc286e",
- "tarball": "http://registry.npmjs.org/q/-/q-1.4.1.tgz"
- },
- "_resolved": "https://registry.npmjs.org/q/-/q-1.4.1.tgz",
- "readme": "ERROR: No README data found!"
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[15/25] cordova-browser git commit: update shelljs version,
prepare is working
Posted by pu...@apache.org.
update shelljs version, prepare is working
Project: http://git-wip-us.apache.org/repos/asf/cordova-browser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-browser/commit/c846b473
Tree: http://git-wip-us.apache.org/repos/asf/cordova-browser/tree/c846b473
Diff: http://git-wip-us.apache.org/repos/asf/cordova-browser/diff/c846b473
Branch: refs/heads/master
Commit: c846b47394eba450e4d283897b823ba36bea8e1a
Parents: 3dadcf7
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Mon May 1 15:19:30 2017 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Mon May 1 15:19:30 2017 -0700
----------------------------------------------------------------------
bin/template/cordova/Api.js | 73 +-
bin/template/cordova/browser_parser.js | 18 +-
node_modules/.bin/shjs | 16 +-
node_modules/shelljs/.idea/.name | 1 -
node_modules/shelljs/.idea/encodings.xml | 6 -
.../inspectionProfiles/Project_Default.xml | 7 -
.../inspectionProfiles/profiles_settings.xml | 7 -
.../shelljs/.idea/jsLibraryMappings.xml | 6 -
.../.idea/libraries/shelljs_node_modules.xml | 14 -
node_modules/shelljs/.idea/misc.xml | 28 -
node_modules/shelljs/.idea/modules.xml | 8 -
node_modules/shelljs/.idea/shelljs.iml | 9 -
node_modules/shelljs/.idea/vcs.xml | 6 -
node_modules/shelljs/.idea/workspace.xml | 764 ------
node_modules/shelljs/.npmignore | 9 -
node_modules/shelljs/MAINTAINERS | 3 -
node_modules/shelljs/README.md | 761 +++---
node_modules/shelljs/bin/shjs | 26 +-
node_modules/shelljs/build/output.js | 2411 ------------------
node_modules/shelljs/global.js | 11 +-
node_modules/shelljs/package.json | 178 +-
node_modules/shelljs/scripts/generate-docs.js | 26 -
node_modules/shelljs/scripts/run-tests.js | 55 -
node_modules/shelljs/shell.js | 186 +-
node_modules/shelljs/src/cat.js | 24 +-
node_modules/shelljs/src/cd.js | 36 +-
node_modules/shelljs/src/chmod.js | 105 +-
node_modules/shelljs/src/common.js | 423 ++-
node_modules/shelljs/src/cp.js | 282 +-
node_modules/shelljs/src/dirs.js | 21 +-
node_modules/shelljs/src/echo.js | 22 +-
node_modules/shelljs/src/error.js | 8 +-
node_modules/shelljs/src/exec.js | 212 +-
node_modules/shelljs/src/find.js | 28 +-
node_modules/shelljs/src/grep.js | 59 +-
node_modules/shelljs/src/ln.js | 23 +-
node_modules/shelljs/src/ls.js | 168 +-
node_modules/shelljs/src/mkdir.js | 55 +-
node_modules/shelljs/src/mv.js | 57 +-
node_modules/shelljs/src/popd.js | 2 +-
node_modules/shelljs/src/pushd.js | 2 +-
node_modules/shelljs/src/pwd.js | 6 +-
node_modules/shelljs/src/rm.js | 123 +-
node_modules/shelljs/src/sed.js | 64 +-
node_modules/shelljs/src/set.js | 20 +-
node_modules/shelljs/src/tempdir.js | 25 +-
node_modules/shelljs/src/test.js | 69 +-
node_modules/shelljs/src/to.js | 27 +-
node_modules/shelljs/src/toEnd.js | 26 +-
node_modules/shelljs/src/touch.js | 35 +-
node_modules/shelljs/src/which.js | 108 +-
package.json | 2 +-
52 files changed, 1948 insertions(+), 4713 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/bin/template/cordova/Api.js
----------------------------------------------------------------------
diff --git a/bin/template/cordova/Api.js b/bin/template/cordova/Api.js
index 720ccdf..1ac420e 100644
--- a/bin/template/cordova/Api.js
+++ b/bin/template/cordova/Api.js
@@ -7,11 +7,15 @@
var shell = require('shelljs');
var path = require('path');
+var fs = require('fs');
var CordovaLogger = require('cordova-common').CordovaLogger;
+var ConfigParser = require('cordova-common').ConfigParser;
var selfEvents = require('cordova-common').events;
+var xmlHelpers = require('cordova-common').xmlHelpers;
-var PLATFORM_NAME = 'testplatform';
+var BrowserParser = require('./browser_parser');
+var PLATFORM_NAME = 'browser';
function setupEvents(externalEventEmitter) {
if (externalEventEmitter) {
@@ -30,6 +34,9 @@ function Api(platform, platformRootDir, events) {
this.platform = platform || PLATFORM_NAME;
this.root = path.resolve(__dirname, '..');
+ this.events = setupEvents(events);
+
+ this.parser = new BrowserParser(this.root);
this.locations = {
platformRootDir: platformRootDir,
@@ -37,19 +44,21 @@ function Api(platform, platformRootDir, events) {
www: path.join(this.root, 'assets/www'),
res: path.join(this.root, 'res'),
platformWww: path.join(this.root, 'platform_www'),
- configXml: path.join(this.root, 'res/xml/config.xml'),
+ configXml: path.join(this.root, 'config.xml'),
defaultConfigXml: path.join(this.root, 'cordova/defaults.xml'),
build: path.join(this.root, 'build'),
// NOTE: Due to platformApi spec we need to return relative paths here
cordovaJs: 'bin/templates/project/assets/www/cordova.js',
cordovaJsSrc: 'cordova-js-src'
};
-
}
Api.createPlatform = function (dest, config, options, events) {
-
- //console.log("browser createPlatform !! dest:" + dest);
+ // console.log("=======================");
+ // console.log("browser createPlatform !! dest:" + dest);
+ // console.log("config=",config);
+ // console.log("options=",options);
+ // console.log("events="+events);
events = setupEvents(events);
var name = "HelloCordova";
@@ -77,8 +86,6 @@ Api.createPlatform = function (dest, config, options, events) {
throw(e);
}
return result;
-
-
};
@@ -96,22 +103,62 @@ Api.prototype.getPlatformInfo = function () {
"root": this.root,
"name": this.platform,
"version": { "version" : "1.0.0" },
- "projectConfig": this._config
+ "projectConfig": this.config
};
};
-Api.prototype.prepare = function (cordovaProject) {
- //console.log("browser-platform:Api:prepare");
- return Promise.resolve();
+Api.prototype.prepare = function (cordovaProject,options) {
+
+ // First cleanup current config and merge project's one into own
+ var defaultConfig = path.join(this.locations.platformRootDir,'cordova',
+ 'defaults.xml');
+
+ var ownConfig = this.locations.configXml;
+
+ var sourceCfg = cordovaProject.projectConfig;
+ // If defaults.xml is present, overwrite platform config.xml with it.
+ // Otherwise save whatever is there as defaults so it can be
+ // restored or copy project config into platform if none exists.
+ if (fs.existsSync(defaultConfig)) {
+ this.events.emit('verbose', 'Generating config.xml from defaults for platform "' + this.platform + '"');
+ shell.cp('-f', defaultConfig, ownConfig);
+ } else if (fs.existsSync(ownConfig)) {
+ shell.cp('-f', ownConfig, defaultConfig);
+ } else {
+ shell.cp('-f', sourceCfg.path, ownConfig);
+ }
+
+ // this._munger.reapply_global_munge().save_all();
+
+ this.config = new ConfigParser(ownConfig);
+ xmlHelpers.mergeXml(cordovaProject.projectConfig.doc.getroot(),
+ this.config.doc.getroot(), this.platform, true);
+ this.config.write();
+
+ /*
+ "browser": {
+ "parser_file": "../cordova/metadata/browser_parser",
+ "handler_file": "../plugman/platforms/browser",
+ "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-browser.git",
+ "version": "~4.1.0",
+ "deprecated": false
+ }
+ */
+
+ // Update own www dir with project's www assets and plugins' assets and js-files
+ this.parser.update_www(cordovaProject.locations.www);
+
+ // update project according to config.xml changes.
+ return this.parser.update_project(this.config, options);
};
Api.prototype.addPlugin = function (plugin, installOptions) {
- //console.log("browser-platform:Api:addPlugin");
+ //console.log("NotImplemented :: browser-platform:Api:addPlugin ",plugin, installOptions);
return Promise.resolve();
};
Api.prototype.removePlugin = function (plugin, uninstallOptions) {
- //console.log("browser-platform:Api:removePlugin");
+ //console.log("NotImplemented :: browser-platform:Api:removePlugin ",plugin, uninstallOptions);
return Promise.resolve();
};
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/bin/template/cordova/browser_parser.js
----------------------------------------------------------------------
diff --git a/bin/template/cordova/browser_parser.js b/bin/template/cordova/browser_parser.js
index eb33f9e..fb0702d 100644
--- a/bin/template/cordova/browser_parser.js
+++ b/bin/template/cordova/browser_parser.js
@@ -66,19 +66,29 @@ browser_parser.prototype.cordovajs_src_path = function(libDir) {
// Replace the www dir with contents of platform_www and app www.
browser_parser.prototype.update_www = function() {
// console.log("updating www");
- return;
var projectRoot = this.path;//util.isCordova(this.path);
- var app_www = projectRoot;//util.projectWww(projectRoot);
+ var app_www = path.join(this.path,"../../www");
var platform_www = path.join(this.path, 'platform_www');
+ var my_www = this.www_dir();
+ console.log("my_www = " + my_www);
+ console.log("projectRoot = " + projectRoot);
+ console.log("app_www = " + app_www);
+
+
// Clear the www dir
shell.rm('-rf', this.www_dir());
shell.mkdir(this.www_dir());
+
// Copy over all app www assets
- shell.cp('-rf', path.join(app_www, '*'), this.www_dir());
+ var srcPath = path.join(app_www,'*');
+ console.log('srcPath = ' + srcPath);
+ var ls = shell.ls(srcPath);
+ console.log('ls ' + ls);
+ shell.cp('-Rf', srcPath, this.www_dir());
// Copy over stock platform www assets (cordova.js)
- shell.cp('-rf', path.join(platform_www, '*'), this.www_dir());
+ //shell.cp('-rf', path.join(platform_www, '*'), this.www_dir());
};
browser_parser.prototype.update_overrides = function() {
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/.bin/shjs
----------------------------------------------------------------------
diff --git a/node_modules/.bin/shjs b/node_modules/.bin/shjs
index 9908675..a044997 120000
--- a/node_modules/.bin/shjs
+++ b/node_modules/.bin/shjs
@@ -1,15 +1 @@
-#!/bin/sh
-basedir=`dirname "$0"`
-
-case `uname` in
- *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
-esac
-
-if [ -x "$basedir/node" ]; then
- "$basedir/node" "$basedir/../shelljs/bin/shjs" "$@"
- ret=$?
-else
- node "$basedir/../shelljs/bin/shjs" "$@"
- ret=$?
-fi
-exit $ret
+../shelljs/bin/shjs
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/.idea/.name
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/.idea/.name b/node_modules/shelljs/.idea/.name
deleted file mode 100644
index 68840c9..0000000
--- a/node_modules/shelljs/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-shelljs
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/.idea/encodings.xml
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/.idea/encodings.xml b/node_modules/shelljs/.idea/encodings.xml
deleted file mode 100644
index 97626ba..0000000
--- a/node_modules/shelljs/.idea/encodings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="Encoding">
- <file url="PROJECT" charset="UTF-8" />
- </component>
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/.idea/inspectionProfiles/Project_Default.xml
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/.idea/inspectionProfiles/Project_Default.xml b/node_modules/shelljs/.idea/inspectionProfiles/Project_Default.xml
deleted file mode 100644
index e6d8387..0000000
--- a/node_modules/shelljs/.idea/inspectionProfiles/Project_Default.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<component name="InspectionProjectProfileManager">
- <profile version="1.0">
- <option name="myName" value="Project Default" />
- <inspection_tool class="JSLastCommaInArrayLiteral" enabled="false" level="WARNING" enabled_by_default="false" />
- <inspection_tool class="JSLastCommaInObjectLiteral" enabled="false" level="WARNING" enabled_by_default="false" />
- </profile>
-</component>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/.idea/inspectionProfiles/profiles_settings.xml
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/.idea/inspectionProfiles/profiles_settings.xml b/node_modules/shelljs/.idea/inspectionProfiles/profiles_settings.xml
deleted file mode 100644
index 3b31283..0000000
--- a/node_modules/shelljs/.idea/inspectionProfiles/profiles_settings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<component name="InspectionProjectProfileManager">
- <settings>
- <option name="PROJECT_PROFILE" value="Project Default" />
- <option name="USE_PROJECT_PROFILE" value="true" />
- <version value="1.0" />
- </settings>
-</component>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/.idea/jsLibraryMappings.xml
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/.idea/jsLibraryMappings.xml b/node_modules/shelljs/.idea/jsLibraryMappings.xml
deleted file mode 100644
index 40bdc77..0000000
--- a/node_modules/shelljs/.idea/jsLibraryMappings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="JavaScriptLibraryMappings">
- <file url="file://$PROJECT_DIR$" libraries="{shelljs node_modules}" />
- </component>
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/.idea/libraries/shelljs_node_modules.xml
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/.idea/libraries/shelljs_node_modules.xml b/node_modules/shelljs/.idea/libraries/shelljs_node_modules.xml
deleted file mode 100644
index b1e5dce..0000000
--- a/node_modules/shelljs/.idea/libraries/shelljs_node_modules.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<component name="libraryTable">
- <library name="shelljs node_modules" type="javaScript">
- <properties>
- <option name="frameworkName" value="node_modules" />
- <sourceFilesUrls>
- <item url="file://$PROJECT_DIR$/node_modules" />
- </sourceFilesUrls>
- </properties>
- <CLASSES>
- <root url="file://$PROJECT_DIR$/node_modules" />
- </CLASSES>
- <SOURCES />
- </library>
-</component>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/.idea/misc.xml
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/.idea/misc.xml b/node_modules/shelljs/.idea/misc.xml
deleted file mode 100644
index f524616..0000000
--- a/node_modules/shelljs/.idea/misc.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="ProjectLevelVcsManager" settingsEditedManually="false">
- <OptionsSetting value="true" id="Add" />
- <OptionsSetting value="true" id="Remove" />
- <OptionsSetting value="true" id="Checkout" />
- <OptionsSetting value="true" id="Update" />
- <OptionsSetting value="true" id="Status" />
- <OptionsSetting value="true" id="Edit" />
- <ConfirmationsSetting value="0" id="Add" />
- <ConfirmationsSetting value="0" id="Remove" />
- </component>
- <component name="masterDetails">
- <states>
- <state key="ScopeChooserConfigurable.UI">
- <settings>
- <splitter-proportions>
- <option name="proportions">
- <list>
- <option value="0.2" />
- </list>
- </option>
- </splitter-proportions>
- </settings>
- </state>
- </states>
- </component>
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/.idea/modules.xml
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/.idea/modules.xml b/node_modules/shelljs/.idea/modules.xml
deleted file mode 100644
index 26f2275..0000000
--- a/node_modules/shelljs/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="ProjectModuleManager">
- <modules>
- <module fileurl="file://$PROJECT_DIR$/.idea/shelljs.iml" filepath="$PROJECT_DIR$/.idea/shelljs.iml" />
- </modules>
- </component>
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/.idea/shelljs.iml
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/.idea/shelljs.iml b/node_modules/shelljs/.idea/shelljs.iml
deleted file mode 100644
index 89f6e57..0000000
--- a/node_modules/shelljs/.idea/shelljs.iml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module type="WEB_MODULE" version="4">
- <component name="NewModuleRootManager">
- <content url="file://$MODULE_DIR$" />
- <orderEntry type="inheritedJdk" />
- <orderEntry type="sourceFolder" forTests="false" />
- <orderEntry type="library" name="shelljs node_modules" level="project" />
- </component>
-</module>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/.idea/vcs.xml
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/.idea/vcs.xml b/node_modules/shelljs/.idea/vcs.xml
deleted file mode 100644
index 94a25f7..0000000
--- a/node_modules/shelljs/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="VcsDirectoryMappings">
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
- </component>
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/.idea/workspace.xml
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/.idea/workspace.xml b/node_modules/shelljs/.idea/workspace.xml
deleted file mode 100644
index 9247ca4..0000000
--- a/node_modules/shelljs/.idea/workspace.xml
+++ /dev/null
@@ -1,764 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="ChangeListManager">
- <list default="true" id="45933638-88e3-4f2a-b91c-9922c650f3b5" name="Default" comment="" />
- <ignored path="shelljs.iws" />
- <ignored path=".idea/workspace.xml" />
- <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
- <option name="TRACKING_ENABLED" value="true" />
- <option name="SHOW_DIALOG" value="false" />
- <option name="HIGHLIGHT_CONFLICTS" value="true" />
- <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
- <option name="LAST_RESOLUTION" value="IGNORE" />
- </component>
- <component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
- <component name="CreatePatchCommitExecutor">
- <option name="PATCH_PATH" value="" />
- </component>
- <component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
- <component name="FavoritesManager">
- <favorites_list name="shelljs" />
- </component>
- <component name="FileEditorManager">
- <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
- <file leaf-file-name="common.js" pinned="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/src/common.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="104" column="7" selection-start-line="104" selection-start-column="7" selection-end-line="104" selection-end-column="7" />
- <folding>
- <marker date="1454630861000" expanded="true" signature="1550:1605" placeholder="//..." />
- <marker date="1454630861000" expanded="true" signature="6173:6214" placeholder="//..." />
- <marker date="1454630861000" expanded="true" signature="6173:6520" placeholder="{...}" />
- <marker date="1454630861000" expanded="true" signature="6173:6891" placeholder="{...}" />
- </folding>
- </state>
- </provider>
- </entry>
- </file>
- <file leaf-file-name="RELEASE.md" pinned="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/RELEASE.md">
- <provider editor-type-id="MarkdownPreviewEditor">
- <state />
- </provider>
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="-0.0">
- <caret line="0" column="15" selection-start-line="0" selection-start-column="15" selection-end-line="0" selection-end-column="15" />
- <folding />
- </state>
- </provider>
- </entry>
- </file>
- <file leaf-file-name="package.json" pinned="false" current-in-tab="true">
- <entry file="file://$PROJECT_DIR$/package.json">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.7058824">
- <caret line="40" column="0" selection-start-line="40" selection-start-column="0" selection-end-line="40" selection-end-column="0" />
- <folding />
- </state>
- </provider>
- </entry>
- </file>
- <file leaf-file-name=".npmignore" pinned="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/.npmignore">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="9" column="0" selection-start-line="9" selection-start-column="0" selection-end-line="9" selection-end-column="0" />
- <folding />
- </state>
- </provider>
- </entry>
- </file>
- <file leaf-file-name="README.md" pinned="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/README.md">
- <provider editor-type-id="MarkdownPreviewEditor">
- <state />
- </provider>
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="-10.928572">
- <caret line="72" column="15" selection-start-line="72" selection-start-column="15" selection-end-line="72" selection-end-column="15" />
- <folding />
- </state>
- </provider>
- </entry>
- </file>
- <file leaf-file-name="shjs" pinned="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/bin/shjs">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- <folding />
- </state>
- </provider>
- </entry>
- </file>
- <file leaf-file-name="output.js" pinned="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/build/output.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- <folding />
- </state>
- </provider>
- </entry>
- </file>
- <file leaf-file-name="cat.js" pinned="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/src/cat.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="38" column="0" selection-start-line="38" selection-start-column="0" selection-end-line="38" selection-end-column="0" />
- <folding>
- <marker date="1454628318000" expanded="true" signature="59:506" placeholder="//..." />
- <marker date="1454628318000" expanded="true" signature="537:958" placeholder="{...}" />
- </folding>
- </state>
- </provider>
- </entry>
- </file>
- </leaf>
- </component>
- <component name="Git.Settings">
- <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
- </component>
- <component name="IdeDocumentHistory">
- <option name="CHANGED_PATHS">
- <list>
- <option value="$PROJECT_DIR$/.eslintrc" />
- <option value="$PROJECT_DIR$/CONTRIBUTING.md" />
- <option value="$PROJECT_DIR$/scripts/run-tests.js" />
- <option value="$PROJECT_DIR$/src/rm.js" />
- <option value="$PROJECT_DIR$/test/resources/issue44/main.js" />
- <option value="$PROJECT_DIR$/test/ln.js" />
- <option value="$PROJECT_DIR$/test/common.js" />
- <option value="$PROJECT_DIR$/src/ln.js" />
- <option value="$PROJECT_DIR$/src/ls.js" />
- <option value="$PROJECT_DIR$/test/which.js" />
- <option value="$PROJECT_DIR$/.eslintrc.json" />
- <option value="$PROJECT_DIR$/src/cat.js" />
- <option value="$PROJECT_DIR$/src/common.js" />
- <option value="$PROJECT_DIR$/test/TODO" />
- <option value="$PROJECT_DIR$/CHANGELOG.md" />
- <option value="$PROJECT_DIR$/maked.js" />
- <option value="$PROJECT_DIR$/docs/my_docs.md" />
- <option value="$PROJECT_DIR$/.npmignore" />
- <option value="$PROJECT_DIR$/m.js" />
- <option value="$PROJECT_DIR$/README.md" />
- <option value="$PROJECT_DIR$/package.json" />
- </list>
- </option>
- </component>
- <component name="JsBuildToolGruntFileManager" detection-done="true" />
- <component name="JsBuildToolPackageJson" detection-done="true">
- <package-json value="$PROJECT_DIR$/package.json" />
- </component>
- <component name="JsGulpfileManager">
- <detection-done>true</detection-done>
- </component>
- <component name="ProjectFrameBounds">
- <option name="width" value="1920" />
- <option name="height" value="1200" />
- </component>
- <component name="ProjectLevelVcsManager" settingsEditedManually="true">
- <OptionsSetting value="true" id="Add" />
- <OptionsSetting value="true" id="Remove" />
- <OptionsSetting value="true" id="Checkout" />
- <OptionsSetting value="true" id="Update" />
- <OptionsSetting value="true" id="Status" />
- <OptionsSetting value="true" id="Edit" />
- <ConfirmationsSetting value="0" id="Add" />
- <ConfirmationsSetting value="0" id="Remove" />
- </component>
- <component name="ProjectView">
- <navigator currentView="ProjectPane" proportions="" version="1">
- <flattenPackages />
- <showMembers />
- <showModules />
- <showLibraryContents />
- <hideEmptyPackages />
- <abbreviatePackageNames />
- <autoscrollToSource />
- <autoscrollFromSource />
- <sortByType />
- <manualOrder />
- <foldersAlwaysOnTop value="true" />
- </navigator>
- <panes>
- <pane id="ProjectPane">
- <subPane>
- <PATH>
- <PATH_ELEMENT>
- <option name="myItemId" value="shelljs" />
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
- </PATH_ELEMENT>
- </PATH>
- <PATH>
- <PATH_ELEMENT>
- <option name="myItemId" value="shelljs" />
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
- </PATH_ELEMENT>
- <PATH_ELEMENT>
- <option name="myItemId" value="shelljs" />
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
- </PATH_ELEMENT>
- </PATH>
- <PATH>
- <PATH_ELEMENT>
- <option name="myItemId" value="shelljs" />
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
- </PATH_ELEMENT>
- <PATH_ELEMENT>
- <option name="myItemId" value="shelljs" />
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
- </PATH_ELEMENT>
- <PATH_ELEMENT>
- <option name="myItemId" value="build" />
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
- </PATH_ELEMENT>
- </PATH>
- <PATH>
- <PATH_ELEMENT>
- <option name="myItemId" value="shelljs" />
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
- </PATH_ELEMENT>
- <PATH_ELEMENT>
- <option name="myItemId" value="shelljs" />
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
- </PATH_ELEMENT>
- <PATH_ELEMENT>
- <option name="myItemId" value="bin" />
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
- </PATH_ELEMENT>
- </PATH>
- </subPane>
- </pane>
- <pane id="Scratches" />
- <pane id="Scope" />
- </panes>
- </component>
- <component name="PropertiesComponent">
- <property name="settings.editor.selected.configurable" value="Markdown" />
- <property name="settings.editor.splitter.proportion" value="0.2" />
- <property name="last_opened_file_path" value="$PROJECT_DIR$" />
- <property name="WebServerToolWindowFactoryState" value="false" />
- <property name="js-jscs-nodeInterpreter" value="$USER_HOME$/n/bin/node" />
- <property name="HbShouldOpenHtmlAsHb" value="" />
- <property name="jsx.switch.disabled" value="true" />
- <property name="FullScreen" value="true" />
- </component>
- <component name="RunManager">
- <configuration default="true" type="BashConfigurationType" factoryName="Bash">
- <option name="INTERPRETER_OPTIONS" value="" />
- <option name="INTERPRETER_PATH" value="/bin/bash" />
- <option name="WORKING_DIRECTORY" value="" />
- <option name="PARENT_ENVS" value="true" />
- <option name="SCRIPT_NAME" value="" />
- <option name="PARAMETERS" value="" />
- <module name="" />
- <envs />
- <method />
- </configuration>
- <configuration default="true" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application">
- <method />
- </configuration>
- <configuration default="true" type="DartTestRunConfigurationType" factoryName="Dart Test">
- <method />
- </configuration>
- <configuration default="true" type="JavaScriptTestRunnerKarma" factoryName="Karma" config-file="">
- <envs />
- <method />
- </configuration>
- <configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug">
- <method />
- </configuration>
- <configuration default="true" type="NodeJSConfigurationType" factoryName="Node.js" working-dir="">
- <method />
- </configuration>
- <configuration default="true" type="cucumber.js" factoryName="Cucumber.js">
- <option name="cucumberJsArguments" value="" />
- <option name="executablePath" />
- <option name="filePath" />
- <method />
- </configuration>
- <configuration default="true" type="js.build_tools.gulp" factoryName="Gulp.js">
- <node-options />
- <gulpfile />
- <tasks />
- <arguments />
- <envs />
- <method />
- </configuration>
- <configuration default="true" type="js.build_tools.npm" factoryName="npm">
- <command value="run-script" />
- <scripts />
- <envs />
- <method />
- </configuration>
- <configuration default="true" type="mocha-javascript-test-runner" factoryName="Mocha">
- <node-options />
- <working-directory>$PROJECT_DIR$</working-directory>
- <pass-parent-env>true</pass-parent-env>
- <envs />
- <ui>bdd</ui>
- <extra-mocha-options />
- <test-kind>DIRECTORY</test-kind>
- <test-directory />
- <recursive>false</recursive>
- <method />
- </configuration>
- </component>
- <component name="ShelveChangesManager" show_recycled="false" />
- <component name="SvnConfiguration">
- <configuration />
- </component>
- <component name="TaskManager">
- <task active="true" id="Default" summary="Default task">
- <changelist id="45933638-88e3-4f2a-b91c-9922c650f3b5" name="Default" comment="" />
- <created>1453951651105</created>
- <option name="number" value="Default" />
- <updated>1453951651105</updated>
- </task>
- <servers />
- </component>
- <component name="ToolWindowManager">
- <frame x="0" y="0" width="1920" height="1200" extended-state="6" />
- <editor active="false" />
- <layout>
- <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.15745129" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
- <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
- <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
- <window_info id="npm" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
- <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
- <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
- <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
- <window_info id="Terminal" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.20318021" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
- <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
- <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
- <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
- <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
- <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
- <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
- <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
- <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
- <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
- </layout>
- </component>
- <component name="Vcs.Log.UiProperties">
- <option name="RECENTLY_FILTERED_USER_GROUPS">
- <collection />
- </option>
- <option name="RECENTLY_FILTERED_BRANCH_GROUPS">
- <collection />
- </option>
- </component>
- <component name="VcsContentAnnotationSettings">
- <option name="myLimit" value="2678400000" />
- </component>
- <component name="XDebuggerManager">
- <breakpoint-manager />
- <watches-manager />
- </component>
- <component name="editorHistoryManager">
- <entry file="file://$PROJECT_DIR$/src/common.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- <folding>
- <marker date="1454630861000" expanded="true" signature="1550:1605" placeholder="//..." />
- <marker date="1454630861000" expanded="true" signature="6173:6214" placeholder="//..." />
- <marker date="1454630861000" expanded="true" signature="6173:6520" placeholder="{...}" />
- <marker date="1454630861000" expanded="true" signature="6173:6891" placeholder="{...}" />
- </folding>
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/shell.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/global.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/.gitignore">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="2" column="0" selection-start-line="2" selection-start-column="0" selection-end-line="2" selection-end-column="0" />
- <folding />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/test/which.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/RELEASE.md">
- <provider editor-type-id="MarkdownPreviewEditor">
- <state />
- </provider>
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/package.json">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="29" column="23" selection-start-line="29" selection-start-column="23" selection-end-line="29" selection-end-column="23" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/README.md">
- <provider editor-type-id="MarkdownPreviewEditor">
- <state />
- </provider>
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="43" column="0" selection-start-line="43" selection-start-column="0" selection-end-line="43" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/scripts/generate-docs.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/scripts/run-tests.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="26" column="50" selection-start-line="26" selection-start-column="50" selection-end-line="26" selection-end-column="50" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/shell.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/global.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/.gitignore">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="2" column="0" selection-start-line="2" selection-start-column="0" selection-end-line="2" selection-end-column="0" />
- <folding />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/test/which.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/RELEASE.md">
- <provider editor-type-id="MarkdownPreviewEditor">
- <state />
- </provider>
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/package.json">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="29" column="23" selection-start-line="29" selection-start-column="23" selection-end-line="29" selection-end-column="23" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/README.md">
- <provider editor-type-id="MarkdownPreviewEditor">
- <state />
- </provider>
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="43" column="0" selection-start-line="43" selection-start-column="0" selection-end-line="43" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/scripts/generate-docs.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/scripts/run-tests.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="26" column="50" selection-start-line="26" selection-start-column="50" selection-end-line="26" selection-end-column="50" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/shell.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/global.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/.gitignore">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- <folding />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/.gitignore">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="2" column="0" selection-start-line="2" selection-start-column="0" selection-end-line="2" selection-end-column="0" />
- <folding />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/scripts/generate-docs.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/test/sed.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="1" column="0" selection-start-line="1" selection-start-column="0" selection-end-line="1" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/src/grep.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/shell.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/global.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/src/sed.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="1" column="0" selection-start-line="1" selection-start-column="0" selection-end-line="1" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/src/pwd.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/scripts/run-tests.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="-0.17814727">
- <caret line="24" column="16" selection-start-line="24" selection-start-column="16" selection-end-line="24" selection-end-column="16" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/test/rm.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="189" column="0" selection-start-line="189" selection-start-column="0" selection-end-line="189" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/node_modules/glob/README.md">
- <provider editor-type-id="MarkdownPreviewEditor">
- <state />
- </provider>
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="30.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/src/rm.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="137" column="25" selection-start-line="137" selection-start-column="25" selection-end-line="137" selection-end-column="25" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/test/resources/issue44/main.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="1" column="0" selection-start-line="1" selection-start-column="0" selection-end-line="1" selection-end-column="0" />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/test/ln.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="20" column="1" selection-start-line="20" selection-start-column="1" selection-end-line="20" selection-end-column="1" />
- <folding />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/test/common.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="46" column="10" selection-start-line="46" selection-start-column="10" selection-end-line="46" selection-end-column="10" />
- <folding />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/test/ls.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="15" column="18" selection-start-line="15" selection-start-column="18" selection-end-line="15" selection-end-column="18" />
- <folding>
- <marker date="1454625654000" expanded="true" signature="11066:11146" placeholder="{...}" />
- </folding>
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/src/ln.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="48" column="9" selection-start-line="48" selection-start-column="9" selection-end-line="48" selection-end-column="9" />
- <folding>
- <marker date="1454625654000" expanded="true" signature="1476:1565" placeholder="{...}" />
- </folding>
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/src/ls.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="168" column="0" selection-start-line="168" selection-start-column="0" selection-end-line="168" selection-end-column="0" />
- <folding />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/test/which.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="19" column="0" selection-start-line="19" selection-start-column="0" selection-end-line="19" selection-end-column="0" />
- <folding>
- <marker date="1454625654000" expanded="true" signature="711:743" placeholder="{...}" />
- </folding>
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/src/cat.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="38" column="0" selection-start-line="38" selection-start-column="0" selection-end-line="38" selection-end-column="0" />
- <folding>
- <marker date="1454628318000" expanded="true" signature="59:506" placeholder="//..." />
- <marker date="1454628318000" expanded="true" signature="537:958" placeholder="{...}" />
- </folding>
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/src/common.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="104" column="7" selection-start-line="104" selection-start-column="7" selection-end-line="104" selection-end-column="7" />
- <folding>
- <marker date="1454630861000" expanded="true" signature="1550:1605" placeholder="//..." />
- <marker date="1454630861000" expanded="true" signature="6173:6214" placeholder="//..." />
- <marker date="1454630861000" expanded="true" signature="6173:6520" placeholder="{...}" />
- <marker date="1454630861000" expanded="true" signature="6173:6891" placeholder="{...}" />
- </folding>
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/.npmignore">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="9" column="0" selection-start-line="9" selection-start-column="0" selection-end-line="9" selection-end-column="0" />
- <folding />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/RELEASE.md">
- <provider editor-type-id="MarkdownPreviewEditor">
- <state />
- </provider>
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="-0.0">
- <caret line="0" column="15" selection-start-line="0" selection-start-column="15" selection-end-line="0" selection-end-column="15" />
- <folding />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/bin/shjs">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- <folding />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/build/output.js">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.0">
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
- <folding />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/README.md">
- <provider editor-type-id="MarkdownPreviewEditor">
- <state />
- </provider>
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="-10.928572">
- <caret line="72" column="15" selection-start-line="72" selection-start-column="15" selection-end-line="72" selection-end-column="15" />
- <folding />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/package.json">
- <provider selected="true" editor-type-id="text-editor">
- <state vertical-scroll-proportion="0.7058824">
- <caret line="40" column="0" selection-start-line="40" selection-start-column="0" selection-end-line="40" selection-end-column="0" />
- <folding />
- </state>
- </provider>
- </entry>
- </component>
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/.npmignore
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/.npmignore b/node_modules/shelljs/.npmignore
deleted file mode 100644
index 8b693ff..0000000
--- a/node_modules/shelljs/.npmignore
+++ /dev/null
@@ -1,9 +0,0 @@
-test/
-tmp/
-.documentup.json
-.gitignore
-.jshintrc
-.lgtm
-.travis.yml
-appveyor.yml
-RELEASE.md
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/MAINTAINERS
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/MAINTAINERS b/node_modules/shelljs/MAINTAINERS
deleted file mode 100644
index 3f94761..0000000
--- a/node_modules/shelljs/MAINTAINERS
+++ /dev/null
@@ -1,3 +0,0 @@
-Ari Porad <ar...@ariporad.com> (@ariporad)
-Nate Fischer <nt...@gmail.com> (@nfischer)
-Artur Adib <ar...@gmail.com> (@arturadib)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[16/25] cordova-browser git commit: added parser,
mostly handling plugin add/remove now
Posted by pu...@apache.org.
added parser, mostly handling plugin add/remove now
Project: http://git-wip-us.apache.org/repos/asf/cordova-browser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-browser/commit/d7cdec35
Tree: http://git-wip-us.apache.org/repos/asf/cordova-browser/tree/d7cdec35
Diff: http://git-wip-us.apache.org/repos/asf/cordova-browser/diff/d7cdec35
Branch: refs/heads/master
Commit: d7cdec35482fac862a8af3a266523d90ebc98696
Parents: c846b47
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu May 4 17:17:55 2017 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu May 4 17:17:55 2017 -0700
----------------------------------------------------------------------
bin/template/cordova/Api.js | 274 ++++++++++++++++++++++++++-
bin/template/cordova/browser_handler.js | 106 +++++++++++
bin/template/cordova/browser_parser.js | 20 +-
3 files changed, 386 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/d7cdec35/bin/template/cordova/Api.js
----------------------------------------------------------------------
diff --git a/bin/template/cordova/Api.js b/bin/template/cordova/Api.js
index 1ac420e..ac1060e 100644
--- a/bin/template/cordova/Api.js
+++ b/bin/template/cordova/Api.js
@@ -11,9 +11,18 @@ var fs = require('fs');
var CordovaLogger = require('cordova-common').CordovaLogger;
var ConfigParser = require('cordova-common').ConfigParser;
+var ActionStack = require('cordova-common').ActionStack;
+var PluginInfo = require('cordova-common').PluginInfo;
var selfEvents = require('cordova-common').events;
var xmlHelpers = require('cordova-common').xmlHelpers;
+
+
+var PlatformJson = require('cordova-common').PlatformJson;
+
+var PlatformMunger = require('cordova-common').ConfigChanges.PlatformMunger;
+var PluginInfoProvider = require('cordova-common').PluginInfoProvider;
+
var BrowserParser = require('./browser_parser');
var PLATFORM_NAME = 'browser';
@@ -37,6 +46,7 @@ function Api(platform, platformRootDir, events) {
this.events = setupEvents(events);
this.parser = new BrowserParser(this.root);
+ this._handler = require('./browser_handler');
this.locations = {
platformRootDir: platformRootDir,
@@ -51,6 +61,10 @@ function Api(platform, platformRootDir, events) {
cordovaJs: 'bin/templates/project/assets/www/cordova.js',
cordovaJsSrc: 'cordova-js-src'
};
+
+ this._platformJson = PlatformJson.load(this.root, platform);
+ this._pluginInfoProvider = new PluginInfoProvider();
+ this._munger = new PlatformMunger(platform, this.root, this._platformJson, this._pluginInfoProvider);
}
Api.createPlatform = function (dest, config, options, events) {
@@ -152,16 +166,270 @@ Api.prototype.prepare = function (cordovaProject,options) {
return this.parser.update_project(this.config, options);
};
-Api.prototype.addPlugin = function (plugin, installOptions) {
- //console.log("NotImplemented :: browser-platform:Api:addPlugin ",plugin, installOptions);
- return Promise.resolve();
+Api.prototype.addPlugin = function (pluginInfo, installOptions) {
+
+ // console.log(new Error().stack);
+
+
+ if (!pluginInfo) {
+ return Promise.reject('The parameter is incorrect. The first parameter ' +
+ 'should be valid PluginInfo instance');
+ }
+
+ installOptions = installOptions || {};
+ installOptions.variables = installOptions.variables || {};
+ // CB-10108 platformVersion option is required for proper plugin installation
+ installOptions.platformVersion = installOptions.platformVersion ||
+ this.getPlatformInfo().version;
+
+ var self = this;
+ var actions = new ActionStack();
+ var projectFile = this._handler.parseProjectFile && this._handler.parseProjectFile(this.root);
+
+ // gather all files needs to be handled during install
+ pluginInfo.getFilesAndFrameworks(this.platform)
+ .concat(pluginInfo.getAssets(this.platform))
+ .concat(pluginInfo.getJsModules(this.platform))
+ .forEach(function(item) {
+ actions.push(actions.createAction(
+ self._getInstaller(item.itemType),
+ [item, pluginInfo.dir, pluginInfo.id, installOptions, projectFile],
+ self._getUninstaller(item.itemType),
+ [item, pluginInfo.dir, pluginInfo.id, installOptions, projectFile]));
+ });
+
+ // run through the action stack
+ return actions.process(this.platform, this.root)
+ .then(function () {
+ if (projectFile) {
+ projectFile.write();
+ }
+
+ // Add PACKAGE_NAME variable into vars
+ if (!installOptions.variables.PACKAGE_NAME) {
+ installOptions.variables.PACKAGE_NAME = self._handler.package_name(self.root);
+ }
+
+ self._munger
+ // Ignore passed `is_top_level` option since platform itself doesn't know
+ // anything about managing dependencies - it's responsibility of caller.
+ .add_plugin_changes(pluginInfo, installOptions.variables, /*is_top_level=*/true, /*should_increment=*/true)
+ .save_all();
+
+ var targetDir = installOptions.usePlatformWww ?
+ self.getPlatformInfo().locations.platformWww :
+ self.getPlatformInfo().locations.www;
+
+ self._addModulesInfo(pluginInfo, targetDir);
+ });
};
Api.prototype.removePlugin = function (plugin, uninstallOptions) {
//console.log("NotImplemented :: browser-platform:Api:removePlugin ",plugin, uninstallOptions);
+
+ uninstallOptions = uninstallOptions || {};
+ // CB-10108 platformVersion option is required for proper plugin installation
+ uninstallOptions.platformVersion = uninstallOptions.platformVersion ||
+ this.getPlatformInfo().version;
+
+ var self = this;
+ var actions = new ActionStack();
+ var projectFile = this._handler.parseProjectFile && this._handler.parseProjectFile(this.root);
+
+ // queue up plugin files
+ plugin.getFilesAndFrameworks(this.platform)
+ .concat(plugin.getAssets(this.platform))
+ .concat(plugin.getJsModules(this.platform))
+ .forEach(function(item) {
+ actions.push(actions.createAction(
+ self._getUninstaller(item.itemType), [item, plugin.dir, plugin.id, uninstallOptions, projectFile],
+ self._getInstaller(item.itemType), [item, plugin.dir, plugin.id, uninstallOptions, projectFile]));
+ });
+
+ // run through the action stack
+ return actions.process(this.platform, this.root)
+ .then(function() {
+ if (projectFile) {
+ projectFile.write();
+ }
+
+ self._munger
+ // Ignore passed `is_top_level` option since platform itself doesn't know
+ // anything about managing dependencies - it's responsibility of caller.
+ .remove_plugin_changes(plugin, /*is_top_level=*/true)
+ .save_all();
+
+ var targetDir = uninstallOptions.usePlatformWww ?
+ self.getPlatformInfo().locations.platformWww :
+ self.getPlatformInfo().locations.www;
+
+ self._removeModulesInfo(plugin, targetDir);
+ // Remove stale plugin directory
+ // TODO: this should be done by plugin files uninstaller
+ shell.rm('-rf', path.resolve(self.root, 'Plugins', plugin.id));
+ });
+
return Promise.resolve();
};
+Api.prototype._getInstaller = function(type) {
+ var self = this;
+ return function (item, plugin_dir, plugin_id, options, project) {
+ var installer = self._handler[type];
+
+ if(!installer) {
+ console.log("unrecognized type " + type)
+ return;
+ }
+ else {
+ var wwwDest = options.usePlatformWww ?
+ self.getPlatformInfo().locations.platformWww :
+ self._handler.www_dir(self.root);
+
+ if(type === 'asset') {
+ installer.install(item, plugin_dir, wwwDest);
+ }
+ else if(type === 'js-module') {
+ installer.install(item, plugin_dir, plugin_id, wwwDest);
+ }
+ else {
+ installer.install(item, plugin_dir, self.root, plugin_id, options, project);
+ }
+
+// var installerArgs = type === 'asset' ? [wwwDest] :
+// type === 'js-module' ? [plugin_id, wwwDest]:
+// [self.root, plugin_id, options, project];
+// installer.install.apply(null, [item, plugin_dir].concat(installerArgs));
+ }
+ };
+};
+
+Api.prototype._getUninstaller = function(type) {
+ var self = this;
+ return function (item, plugin_dir, plugin_id, options, project) {
+ var installer = self._handler[type];
+
+ if(!installer) {
+ console.log("browser plugin uninstall: unrecognized type, skipping : " + type);
+ return;
+ }
+ else {
+ var wwwDest = options.usePlatformWww ?
+ self.getPlatformInfo().locations.platformWww :
+ self._handler.www_dir(self.root);
+
+ if(['asset','js-module'].indexOf(type) > -1) {
+ return installer.uninstall(item, wwwDest, plugin_id);
+ }
+ else {
+ return installer.uninstall(item, self.root, plugin_id, options, project);
+ }
+
+ }
+ };
+};
+
+/**
+ * Removes the specified modules from list of installed modules and updates
+ * platform_json and cordova_plugins.js on disk.
+ *
+ * @param {PluginInfo} plugin PluginInfo instance for plugin, which modules
+ * needs to be added.
+ * @param {String} targetDir The directory, where updated cordova_plugins.js
+ * should be written to.
+ */
+Api.prototype._addModulesInfo = function(plugin, targetDir) {
+ var installedModules = this._platformJson.root.modules || [];
+
+ var installedPaths = installedModules.map(function (installedModule) {
+ return installedModule.file;
+ });
+
+ var modulesToInstall = plugin.getJsModules(this.platform)
+ .filter(function (moduleToInstall) {
+ return installedPaths.indexOf(moduleToInstall.file) === -1;
+ }).map(function (moduleToInstall) {
+ var moduleName = plugin.id + '.' + ( moduleToInstall.name || moduleToInstall.src.match(/([^\/]+)\.js/)[1] );
+ var obj = {
+ file: ['plugins', plugin.id, moduleToInstall.src].join('/'),
+ id: moduleName,
+ pluginId: plugin.id
+ };
+ if (moduleToInstall.clobbers.length > 0) {
+ obj.clobbers = moduleToInstall.clobbers.map(function(o) { return o.target; });
+ }
+ if (moduleToInstall.merges.length > 0) {
+ obj.merges = moduleToInstall.merges.map(function(o) { return o.target; });
+ }
+ if (moduleToInstall.runs) {
+ obj.runs = true;
+ }
+
+ return obj;
+ });
+
+ this._platformJson.root.modules = installedModules.concat(modulesToInstall);
+ if (!this._platformJson.root.plugin_metadata) {
+ this._platformJson.root.plugin_metadata = {};
+ }
+ this._platformJson.root.plugin_metadata[plugin.id] = plugin.version;
+
+ this._writePluginModules(targetDir);
+ this._platformJson.save();
+};
+/**
+ * Fetches all installed modules, generates cordova_plugins contents and writes
+ * it to file.
+ *
+ * @param {String} targetDir Directory, where write cordova_plugins.js to.
+ * Ususally it is either <platform>/www or <platform>/platform_www
+ * directories.
+ */
+Api.prototype._writePluginModules = function (targetDir) {
+ // Write out moduleObjects as JSON wrapped in a cordova module to cordova_plugins.js
+ var final_contents = 'cordova.define(\'cordova/plugin_list\', function(require, exports, module) {\n';
+ final_contents += 'module.exports = ' + JSON.stringify(this._platformJson.root.modules, null, ' ') + ';\n';
+ final_contents += 'module.exports.metadata = \n';
+ final_contents += '// TOP OF METADATA\n';
+ final_contents += JSON.stringify(this._platformJson.root.plugin_metadata || {}, null, ' ') + '\n';
+ final_contents += '// BOTTOM OF METADATA\n';
+ final_contents += '});'; // Close cordova.define.
+
+ shell.mkdir('-p', targetDir);
+ fs.writeFileSync(path.join(targetDir, 'cordova_plugins.js'), final_contents, 'utf-8');
+};
+
+
+/**
+ * Removes the specified modules from list of installed modules and updates
+ * platform_json and cordova_plugins.js on disk.
+ *
+ * @param {PluginInfo} plugin PluginInfo instance for plugin, which modules
+ * needs to be removed.
+ * @param {String} targetDir The directory, where updated cordova_plugins.js
+ * should be written to.
+ */
+Api.prototype._removeModulesInfo = function(plugin, targetDir) {
+ var installedModules = this._platformJson.root.modules || [];
+ var modulesToRemove = plugin.getJsModules(this.platform)
+ .map(function (jsModule) {
+ return ['plugins', plugin.id, jsModule.src].join('/');
+ });
+
+ var updatedModules = installedModules
+ .filter(function (installedModule) {
+ return (modulesToRemove.indexOf(installedModule.file) === -1);
+ });
+
+ this._platformJson.root.modules = updatedModules;
+ if (this._platformJson.root.plugin_metadata) {
+ delete this._platformJson.root.plugin_metadata[plugin.id];
+ }
+
+ this._writePluginModules(targetDir);
+ this._platformJson.save();
+};
+
Api.prototype.build = function (buildOptions) {
var self = this;
return require('./lib/check_reqs').run()
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/d7cdec35/bin/template/cordova/browser_handler.js
----------------------------------------------------------------------
diff --git a/bin/template/cordova/browser_handler.js b/bin/template/cordova/browser_handler.js
new file mode 100644
index 0000000..101fc13
--- /dev/null
+++ b/bin/template/cordova/browser_handler.js
@@ -0,0 +1,106 @@
+/**
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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 path = require('path');
+var fs = require('fs');
+var shell = require('shelljs');
+
+
+var events = require('cordova-common').events;
+
+module.exports = {
+ www_dir: function(project_dir) {
+ return path.join(project_dir, 'www');
+ },
+ package_name:function(project_dir) {
+ //return common.package_name(project_dir, this.www_dir(project_dir));
+ console.log('package_name called with ' + project_dir);
+ return 'bob';
+ },
+ 'js-module': {
+ install: function (jsModule, plugin_dir, plugin_id, www_dir) {
+ // Copy the plugin's files into the www directory.
+ var moduleSource = path.resolve(plugin_dir, jsModule.src);
+ // Get module name based on existing 'name' attribute or filename
+ // Must use path.extname/path.basename instead of path.parse due to CB-9981
+ var moduleName = plugin_id + '.' + (jsModule.name || path.basename(jsModule.src, path.extname (jsModule.src)));
+
+ // Read in the file, prepend the cordova.define, and write it back out.
+ var scriptContent = fs.readFileSync(moduleSource, 'utf-8').replace(/^\ufeff/, ''); // Window BOM
+ if (moduleSource.match(/.*\.json$/)) {
+ scriptContent = 'module.exports = ' + scriptContent;
+ }
+ scriptContent = 'cordova.define("' + moduleName + '", function(require, exports, module) { ' + scriptContent + '\n});\n';
+
+ var moduleDestination = path.resolve(www_dir, 'plugins', plugin_id, jsModule.src);
+ shell.mkdir('-p', path.dirname(moduleDestination));
+ fs.writeFileSync(moduleDestination, scriptContent, 'utf-8');
+ },
+ uninstall: function (jsModule, www_dir, plugin_id) {
+ var pluginRelativePath = path.join('plugins', plugin_id, jsModule.src);
+ // common.removeFileAndParents(www_dir, pluginRelativePath);
+ console.log("js-module uninstall called : " + pluginRelativePath);
+ }
+ },
+ 'source-file':{
+ install:function(obj, plugin_dir, project_dir, plugin_id, options) {
+ // var dest = path.join(obj.targetDir, path.basename(obj.src));
+ // common.copyFile(plugin_dir, obj.src, project_dir, dest);
+ console.log("install called");
+ },
+ uninstall:function(obj, project_dir, plugin_id, options) {
+ // var dest = path.join(obj.targetDir, path.basename(obj.src));
+ // common.removeFile(project_dir, dest);
+ console.log("uninstall called");
+ }
+ },
+ 'header-file': {
+ install:function(obj, plugin_dir, project_dir, plugin_id, options) {
+ events.emit('verbose', 'header-fileinstall is not supported for browser');
+ },
+ uninstall:function(obj, project_dir, plugin_id, options) {
+ events.emit('verbose', 'header-file.uninstall is not supported for browser');
+ }
+ },
+ 'resource-file':{
+ install:function(obj, plugin_dir, project_dir, plugin_id, options) {
+ events.emit('verbose', 'resource-file.install is not supported for browser');
+ },
+ uninstall:function(obj, project_dir, plugin_id, options) {
+ events.emit('verbose', 'resource-file.uninstall is not supported for browser');
+ }
+ },
+ 'framework': {
+ install:function(obj, plugin_dir, project_dir, plugin_id, options) {
+ events.emit('verbose', 'framework.install is not supported for browser');
+ },
+ uninstall:function(obj, project_dir, plugin_id, options) {
+ events.emit('verbose', 'framework.uninstall is not supported for browser');
+ }
+ },
+ 'lib-file': {
+ install:function(obj, plugin_dir, project_dir, plugin_id, options) {
+ events.emit('verbose', 'lib-file.install is not supported for browser');
+ },
+ uninstall:function(obj, project_dir, plugin_id, options) {
+ events.emit('verbose', 'lib-file.uninstall is not supported for browser');
+ }
+ }
+};
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/d7cdec35/bin/template/cordova/browser_parser.js
----------------------------------------------------------------------
diff --git a/bin/template/cordova/browser_parser.js b/bin/template/cordova/browser_parser.js
index fb0702d..7efa837 100644
--- a/bin/template/cordova/browser_parser.js
+++ b/bin/template/cordova/browser_parser.js
@@ -76,31 +76,29 @@ browser_parser.prototype.update_www = function() {
console.log("projectRoot = " + projectRoot);
console.log("app_www = " + app_www);
-
// Clear the www dir
shell.rm('-rf', this.www_dir());
shell.mkdir(this.www_dir());
// Copy over all app www assets
var srcPath = path.join(app_www,'*');
- console.log('srcPath = ' + srcPath);
+
var ls = shell.ls(srcPath);
- console.log('ls ' + ls);
- shell.cp('-Rf', srcPath, this.www_dir());
+ shell.cp('-rf', srcPath, this.www_dir());
// Copy over stock platform www assets (cordova.js)
- //shell.cp('-rf', path.join(platform_www, '*'), this.www_dir());
+ shell.cp('-rf', path.join(platform_www, '*'), this.www_dir());
};
browser_parser.prototype.update_overrides = function() {
console.log("update_overrides");
return;
- var projectRoot = util.isCordova(this.path);
- var mergesPath = path.join(util.appDir(projectRoot), 'merges', 'browser');
- if(fs.existsSync(mergesPath)) {
- var overrides = path.join(mergesPath, '*');
- shell.cp('-rf', overrides, this.www_dir());
- }
+ // var projectRoot = util.isCordova(this.path);
+ // var mergesPath = path.join(util.appDir(projectRoot), 'merges', 'browser');
+ // if(fs.existsSync(mergesPath)) {
+ // var overrides = path.join(mergesPath, '*');
+ // shell.cp('-rf', overrides, this.www_dir());
+ // }
};
browser_parser.prototype.config_xml = function(){
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[10/25] cordova-browser git commit: added browser_parser
Posted by pu...@apache.org.
added browser_parser
Project: http://git-wip-us.apache.org/repos/asf/cordova-browser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-browser/commit/3dadcf75
Tree: http://git-wip-us.apache.org/repos/asf/cordova-browser/tree/3dadcf75
Diff: http://git-wip-us.apache.org/repos/asf/cordova-browser/diff/3dadcf75
Branch: refs/heads/master
Commit: 3dadcf758366cf3f619fc819a7055bbe99b89e9f
Parents: 22b8a25
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Apr 25 17:25:08 2017 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Apr 25 17:25:08 2017 -0700
----------------------------------------------------------------------
bin/template/cordova/browser_parser.js | 112 ++++++++++++++++++++++++++++
1 file changed, 112 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/3dadcf75/bin/template/cordova/browser_parser.js
----------------------------------------------------------------------
diff --git a/bin/template/cordova/browser_parser.js b/bin/template/cordova/browser_parser.js
new file mode 100644
index 0000000..eb33f9e
--- /dev/null
+++ b/bin/template/cordova/browser_parser.js
@@ -0,0 +1,112 @@
+/**
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+*/
+
+/* jshint sub:true */
+
+
+
+var fs = require('fs'),
+ path = require('path'),
+ shell = require('shelljs'),
+ //util = require('../util'),
+ CordovaError = require('cordova-common').CordovaError,
+ Q = require('q');
+
+function dirExists(dir) {
+ return fs.existsSync(dir) && fs.statSync(dir).isDirectory();
+}
+
+function browser_parser(project) {
+ if (!dirExists(project) || !dirExists(path.join(project, 'cordova'))) {
+ throw new CordovaError('The provided path "' + project + '" is not a valid browser project.');
+ }
+ this.path = project;
+}
+
+
+module.exports = browser_parser;
+
+// Returns a promise.
+browser_parser.prototype.update_from_config = function() {
+ return Promise.resolve();
+};
+
+browser_parser.prototype.www_dir = function() {
+ return path.join(this.path, 'www');
+};
+
+// Used for creating platform_www in projects created by older versions.
+browser_parser.prototype.cordovajs_path = function(libDir) {
+ var jsPath = path.join(libDir, 'cordova-lib', 'cordova.js');
+ return path.resolve(jsPath);
+};
+
+browser_parser.prototype.cordovajs_src_path = function(libDir) {
+ console.log("cordovajs_src_path");
+ var jsPath = path.join(libDir, 'cordova-js-src');
+ return path.resolve(jsPath);
+};
+
+// Replace the www dir with contents of platform_www and app www.
+browser_parser.prototype.update_www = function() {
+ // console.log("updating www");
+ return;
+
+ var projectRoot = this.path;//util.isCordova(this.path);
+ var app_www = projectRoot;//util.projectWww(projectRoot);
+ var platform_www = path.join(this.path, 'platform_www');
+
+ // Clear the www dir
+ shell.rm('-rf', this.www_dir());
+ shell.mkdir(this.www_dir());
+ // Copy over all app www assets
+ shell.cp('-rf', path.join(app_www, '*'), this.www_dir());
+ // Copy over stock platform www assets (cordova.js)
+ shell.cp('-rf', path.join(platform_www, '*'), this.www_dir());
+};
+
+browser_parser.prototype.update_overrides = function() {
+ console.log("update_overrides");
+ return;
+
+ var projectRoot = util.isCordova(this.path);
+ var mergesPath = path.join(util.appDir(projectRoot), 'merges', 'browser');
+ if(fs.existsSync(mergesPath)) {
+ var overrides = path.join(mergesPath, '*');
+ shell.cp('-rf', overrides, this.www_dir());
+ }
+};
+
+browser_parser.prototype.config_xml = function(){
+ console.log("config_xml ");
+ return path.join(this.path, 'config.xml');
+};
+
+// Returns a promise.
+browser_parser.prototype.update_project = function(cfg) {
+ console.log("update_project ",cfg);
+ return this.update_from_config()
+ .then(function(){
+ this.update_overrides();
+ // util.deleteSvnFolders(this.www_dir());
+
+ // Copy munged config.xml to platform www dir
+ shell.cp('-rf', path.join(this.www_dir(), '..', 'config.xml'), this.www_dir());
+ }.bind(this));
+};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[22/25] cordova-browser git commit: remove excessive console logging
Posted by pu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/adfd7874/node_modules/q/q.js
----------------------------------------------------------------------
diff --git a/node_modules/q/q.js b/node_modules/q/q.js
deleted file mode 100644
index cf5339e..0000000
--- a/node_modules/q/q.js
+++ /dev/null
@@ -1,2048 +0,0 @@
-// vim:ts=4:sts=4:sw=4:
-/*!
- *
- * Copyright 2009-2012 Kris Kowal under the terms of the MIT
- * license found at http://github.com/kriskowal/q/raw/master/LICENSE
- *
- * With parts by Tyler Close
- * Copyright 2007-2009 Tyler Close under the terms of the MIT X license found
- * at http://www.opensource.org/licenses/mit-license.html
- * Forked at ref_send.js version: 2009-05-11
- *
- * With parts by Mark Miller
- * Copyright (C) 2011 Google Inc.
- *
- * 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.
- *
- */
-
-(function (definition) {
- "use strict";
-
- // This file will function properly as a <script> tag, or a module
- // using CommonJS and NodeJS or RequireJS module formats. In
- // Common/Node/RequireJS, the module exports the Q API and when
- // executed as a simple <script>, it creates a Q global instead.
-
- // Montage Require
- if (typeof bootstrap === "function") {
- bootstrap("promise", definition);
-
- // CommonJS
- } else if (typeof exports === "object" && typeof module === "object") {
- module.exports = definition();
-
- // RequireJS
- } else if (typeof define === "function" && define.amd) {
- define(definition);
-
- // SES (Secure EcmaScript)
- } else if (typeof ses !== "undefined") {
- if (!ses.ok()) {
- return;
- } else {
- ses.makeQ = definition;
- }
-
- // <script>
- } else if (typeof window !== "undefined" || typeof self !== "undefined") {
- // Prefer window over self for add-on scripts. Use self for
- // non-windowed contexts.
- var global = typeof window !== "undefined" ? window : self;
-
- // Get the `window` object, save the previous Q global
- // and initialize Q as a global.
- var previousQ = global.Q;
- global.Q = definition();
-
- // Add a noConflict function so Q can be removed from the
- // global namespace.
- global.Q.noConflict = function () {
- global.Q = previousQ;
- return this;
- };
-
- } else {
- throw new Error("This environment was not anticipated by Q. Please file a bug.");
- }
-
-})(function () {
-"use strict";
-
-var hasStacks = false;
-try {
- throw new Error();
-} catch (e) {
- hasStacks = !!e.stack;
-}
-
-// All code after this point will be filtered from stack traces reported
-// by Q.
-var qStartingLine = captureLine();
-var qFileName;
-
-// shims
-
-// used for fallback in "allResolved"
-var noop = function () {};
-
-// Use the fastest possible means to execute a task in a future turn
-// of the event loop.
-var nextTick =(function () {
- // linked list of tasks (single, with head node)
- var head = {task: void 0, next: null};
- var tail = head;
- var flushing = false;
- var requestTick = void 0;
- var isNodeJS = false;
- // queue for late tasks, used by unhandled rejection tracking
- var laterQueue = [];
-
- function flush() {
- /* jshint loopfunc: true */
- var task, domain;
-
- while (head.next) {
- head = head.next;
- task = head.task;
- head.task = void 0;
- domain = head.domain;
-
- if (domain) {
- head.domain = void 0;
- domain.enter();
- }
- runSingle(task, domain);
-
- }
- while (laterQueue.length) {
- task = laterQueue.pop();
- runSingle(task);
- }
- flushing = false;
- }
- // runs a single function in the async queue
- function runSingle(task, domain) {
- try {
- task();
-
- } catch (e) {
- if (isNodeJS) {
- // In node, uncaught exceptions are considered fatal errors.
- // Re-throw them synchronously to interrupt flushing!
-
- // Ensure continuation if the uncaught exception is suppressed
- // listening "uncaughtException" events (as domains does).
- // Continue in next event to avoid tick recursion.
- if (domain) {
- domain.exit();
- }
- setTimeout(flush, 0);
- if (domain) {
- domain.enter();
- }
-
- throw e;
-
- } else {
- // In browsers, uncaught exceptions are not fatal.
- // Re-throw them asynchronously to avoid slow-downs.
- setTimeout(function () {
- throw e;
- }, 0);
- }
- }
-
- if (domain) {
- domain.exit();
- }
- }
-
- nextTick = function (task) {
- tail = tail.next = {
- task: task,
- domain: isNodeJS && process.domain,
- next: null
- };
-
- if (!flushing) {
- flushing = true;
- requestTick();
- }
- };
-
- if (typeof process === "object" &&
- process.toString() === "[object process]" && process.nextTick) {
- // Ensure Q is in a real Node environment, with a `process.nextTick`.
- // To see through fake Node environments:
- // * Mocha test runner - exposes a `process` global without a `nextTick`
- // * Browserify - exposes a `process.nexTick` function that uses
- // `setTimeout`. In this case `setImmediate` is preferred because
- // it is faster. Browserify's `process.toString()` yields
- // "[object Object]", while in a real Node environment
- // `process.nextTick()` yields "[object process]".
- isNodeJS = true;
-
- requestTick = function () {
- process.nextTick(flush);
- };
-
- } else if (typeof setImmediate === "function") {
- // In IE10, Node.js 0.9+, or https://github.com/NobleJS/setImmediate
- if (typeof window !== "undefined") {
- requestTick = setImmediate.bind(window, flush);
- } else {
- requestTick = function () {
- setImmediate(flush);
- };
- }
-
- } else if (typeof MessageChannel !== "undefined") {
- // modern browsers
- // http://www.nonblocking.io/2011/06/windownexttick.html
- var channel = new MessageChannel();
- // At least Safari Version 6.0.5 (8536.30.1) intermittently cannot create
- // working message ports the first time a page loads.
- channel.port1.onmessage = function () {
- requestTick = requestPortTick;
- channel.port1.onmessage = flush;
- flush();
- };
- var requestPortTick = function () {
- // Opera requires us to provide a message payload, regardless of
- // whether we use it.
- channel.port2.postMessage(0);
- };
- requestTick = function () {
- setTimeout(flush, 0);
- requestPortTick();
- };
-
- } else {
- // old browsers
- requestTick = function () {
- setTimeout(flush, 0);
- };
- }
- // runs a task after all other tasks have been run
- // this is useful for unhandled rejection tracking that needs to happen
- // after all `then`d tasks have been run.
- nextTick.runAfter = function (task) {
- laterQueue.push(task);
- if (!flushing) {
- flushing = true;
- requestTick();
- }
- };
- return nextTick;
-})();
-
-// Attempt to make generics safe in the face of downstream
-// modifications.
-// There is no situation where this is necessary.
-// If you need a security guarantee, these primordials need to be
-// deeply frozen anyway, and if you don’t need a security guarantee,
-// this is just plain paranoid.
-// However, this **might** have the nice side-effect of reducing the size of
-// the minified code by reducing x.call() to merely x()
-// See Mark Miller’s explanation of what this does.
-// http://wiki.ecmascript.org/doku.php?id=conventions:safe_meta_programming
-var call = Function.call;
-function uncurryThis(f) {
- return function () {
- return call.apply(f, arguments);
- };
-}
-// This is equivalent, but slower:
-// uncurryThis = Function_bind.bind(Function_bind.call);
-// http://jsperf.com/uncurrythis
-
-var array_slice = uncurryThis(Array.prototype.slice);
-
-var array_reduce = uncurryThis(
- Array.prototype.reduce || function (callback, basis) {
- var index = 0,
- length = this.length;
- // concerning the initial value, if one is not provided
- if (arguments.length === 1) {
- // seek to the first value in the array, accounting
- // for the possibility that is is a sparse array
- do {
- if (index in this) {
- basis = this[index++];
- break;
- }
- if (++index >= length) {
- throw new TypeError();
- }
- } while (1);
- }
- // reduce
- for (; index < length; index++) {
- // account for the possibility that the array is sparse
- if (index in this) {
- basis = callback(basis, this[index], index);
- }
- }
- return basis;
- }
-);
-
-var array_indexOf = uncurryThis(
- Array.prototype.indexOf || function (value) {
- // not a very good shim, but good enough for our one use of it
- for (var i = 0; i < this.length; i++) {
- if (this[i] === value) {
- return i;
- }
- }
- return -1;
- }
-);
-
-var array_map = uncurryThis(
- Array.prototype.map || function (callback, thisp) {
- var self = this;
- var collect = [];
- array_reduce(self, function (undefined, value, index) {
- collect.push(callback.call(thisp, value, index, self));
- }, void 0);
- return collect;
- }
-);
-
-var object_create = Object.create || function (prototype) {
- function Type() { }
- Type.prototype = prototype;
- return new Type();
-};
-
-var object_hasOwnProperty = uncurryThis(Object.prototype.hasOwnProperty);
-
-var object_keys = Object.keys || function (object) {
- var keys = [];
- for (var key in object) {
- if (object_hasOwnProperty(object, key)) {
- keys.push(key);
- }
- }
- return keys;
-};
-
-var object_toString = uncurryThis(Object.prototype.toString);
-
-function isObject(value) {
- return value === Object(value);
-}
-
-// generator related shims
-
-// FIXME: Remove this function once ES6 generators are in SpiderMonkey.
-function isStopIteration(exception) {
- return (
- object_toString(exception) === "[object StopIteration]" ||
- exception instanceof QReturnValue
- );
-}
-
-// FIXME: Remove this helper and Q.return once ES6 generators are in
-// SpiderMonkey.
-var QReturnValue;
-if (typeof ReturnValue !== "undefined") {
- QReturnValue = ReturnValue;
-} else {
- QReturnValue = function (value) {
- this.value = value;
- };
-}
-
-// long stack traces
-
-var STACK_JUMP_SEPARATOR = "From previous event:";
-
-function makeStackTraceLong(error, promise) {
- // If possible, transform the error stack trace by removing Node and Q
- // cruft, then concatenating with the stack trace of `promise`. See #57.
- if (hasStacks &&
- promise.stack &&
- typeof error === "object" &&
- error !== null &&
- error.stack &&
- error.stack.indexOf(STACK_JUMP_SEPARATOR) === -1
- ) {
- var stacks = [];
- for (var p = promise; !!p; p = p.source) {
- if (p.stack) {
- stacks.unshift(p.stack);
- }
- }
- stacks.unshift(error.stack);
-
- var concatedStacks = stacks.join("\n" + STACK_JUMP_SEPARATOR + "\n");
- error.stack = filterStackString(concatedStacks);
- }
-}
-
-function filterStackString(stackString) {
- var lines = stackString.split("\n");
- var desiredLines = [];
- for (var i = 0; i < lines.length; ++i) {
- var line = lines[i];
-
- if (!isInternalFrame(line) && !isNodeFrame(line) && line) {
- desiredLines.push(line);
- }
- }
- return desiredLines.join("\n");
-}
-
-function isNodeFrame(stackLine) {
- return stackLine.indexOf("(module.js:") !== -1 ||
- stackLine.indexOf("(node.js:") !== -1;
-}
-
-function getFileNameAndLineNumber(stackLine) {
- // Named functions: "at functionName (filename:lineNumber:columnNumber)"
- // In IE10 function name can have spaces ("Anonymous function") O_o
- var attempt1 = /at .+ \((.+):(\d+):(?:\d+)\)$/.exec(stackLine);
- if (attempt1) {
- return [attempt1[1], Number(attempt1[2])];
- }
-
- // Anonymous functions: "at filename:lineNumber:columnNumber"
- var attempt2 = /at ([^ ]+):(\d+):(?:\d+)$/.exec(stackLine);
- if (attempt2) {
- return [attempt2[1], Number(attempt2[2])];
- }
-
- // Firefox style: "function@filename:lineNumber or @filename:lineNumber"
- var attempt3 = /.*@(.+):(\d+)$/.exec(stackLine);
- if (attempt3) {
- return [attempt3[1], Number(attempt3[2])];
- }
-}
-
-function isInternalFrame(stackLine) {
- var fileNameAndLineNumber = getFileNameAndLineNumber(stackLine);
-
- if (!fileNameAndLineNumber) {
- return false;
- }
-
- var fileName = fileNameAndLineNumber[0];
- var lineNumber = fileNameAndLineNumber[1];
-
- return fileName === qFileName &&
- lineNumber >= qStartingLine &&
- lineNumber <= qEndingLine;
-}
-
-// discover own file name and line number range for filtering stack
-// traces
-function captureLine() {
- if (!hasStacks) {
- return;
- }
-
- try {
- throw new Error();
- } catch (e) {
- var lines = e.stack.split("\n");
- var firstLine = lines[0].indexOf("@") > 0 ? lines[1] : lines[2];
- var fileNameAndLineNumber = getFileNameAndLineNumber(firstLine);
- if (!fileNameAndLineNumber) {
- return;
- }
-
- qFileName = fileNameAndLineNumber[0];
- return fileNameAndLineNumber[1];
- }
-}
-
-function deprecate(callback, name, alternative) {
- return function () {
- if (typeof console !== "undefined" &&
- typeof console.warn === "function") {
- console.warn(name + " is deprecated, use " + alternative +
- " instead.", new Error("").stack);
- }
- return callback.apply(callback, arguments);
- };
-}
-
-// end of shims
-// beginning of real work
-
-/**
- * Constructs a promise for an immediate reference, passes promises through, or
- * coerces promises from different systems.
- * @param value immediate reference or promise
- */
-function Q(value) {
- // If the object is already a Promise, return it directly. This enables
- // the resolve function to both be used to created references from objects,
- // but to tolerably coerce non-promises to promises.
- if (value instanceof Promise) {
- return value;
- }
-
- // assimilate thenables
- if (isPromiseAlike(value)) {
- return coerce(value);
- } else {
- return fulfill(value);
- }
-}
-Q.resolve = Q;
-
-/**
- * Performs a task in a future turn of the event loop.
- * @param {Function} task
- */
-Q.nextTick = nextTick;
-
-/**
- * Controls whether or not long stack traces will be on
- */
-Q.longStackSupport = false;
-
-// enable long stacks if Q_DEBUG is set
-if (typeof process === "object" && process && process.env && process.env.Q_DEBUG) {
- Q.longStackSupport = true;
-}
-
-/**
- * Constructs a {promise, resolve, reject} object.
- *
- * `resolve` is a callback to invoke with a more resolved value for the
- * promise. To fulfill the promise, invoke `resolve` with any value that is
- * not a thenable. To reject the promise, invoke `resolve` with a rejected
- * thenable, or invoke `reject` with the reason directly. To resolve the
- * promise to another thenable, thus putting it in the same state, invoke
- * `resolve` with that other thenable.
- */
-Q.defer = defer;
-function defer() {
- // if "messages" is an "Array", that indicates that the promise has not yet
- // been resolved. If it is "undefined", it has been resolved. Each
- // element of the messages array is itself an array of complete arguments to
- // forward to the resolved promise. We coerce the resolution value to a
- // promise using the `resolve` function because it handles both fully
- // non-thenable values and other thenables gracefully.
- var messages = [], progressListeners = [], resolvedPromise;
-
- var deferred = object_create(defer.prototype);
- var promise = object_create(Promise.prototype);
-
- promise.promiseDispatch = function (resolve, op, operands) {
- var args = array_slice(arguments);
- if (messages) {
- messages.push(args);
- if (op === "when" && operands[1]) { // progress operand
- progressListeners.push(operands[1]);
- }
- } else {
- Q.nextTick(function () {
- resolvedPromise.promiseDispatch.apply(resolvedPromise, args);
- });
- }
- };
-
- // XXX deprecated
- promise.valueOf = function () {
- if (messages) {
- return promise;
- }
- var nearerValue = nearer(resolvedPromise);
- if (isPromise(nearerValue)) {
- resolvedPromise = nearerValue; // shorten chain
- }
- return nearerValue;
- };
-
- promise.inspect = function () {
- if (!resolvedPromise) {
- return { state: "pending" };
- }
- return resolvedPromise.inspect();
- };
-
- if (Q.longStackSupport && hasStacks) {
- try {
- throw new Error();
- } catch (e) {
- // NOTE: don't try to use `Error.captureStackTrace` or transfer the
- // accessor around; that causes memory leaks as per GH-111. Just
- // reify the stack trace as a string ASAP.
- //
- // At the same time, cut off the first line; it's always just
- // "[object Promise]\n", as per the `toString`.
- promise.stack = e.stack.substring(e.stack.indexOf("\n") + 1);
- }
- }
-
- // NOTE: we do the checks for `resolvedPromise` in each method, instead of
- // consolidating them into `become`, since otherwise we'd create new
- // promises with the lines `become(whatever(value))`. See e.g. GH-252.
-
- function become(newPromise) {
- resolvedPromise = newPromise;
- promise.source = newPromise;
-
- array_reduce(messages, function (undefined, message) {
- Q.nextTick(function () {
- newPromise.promiseDispatch.apply(newPromise, message);
- });
- }, void 0);
-
- messages = void 0;
- progressListeners = void 0;
- }
-
- deferred.promise = promise;
- deferred.resolve = function (value) {
- if (resolvedPromise) {
- return;
- }
-
- become(Q(value));
- };
-
- deferred.fulfill = function (value) {
- if (resolvedPromise) {
- return;
- }
-
- become(fulfill(value));
- };
- deferred.reject = function (reason) {
- if (resolvedPromise) {
- return;
- }
-
- become(reject(reason));
- };
- deferred.notify = function (progress) {
- if (resolvedPromise) {
- return;
- }
-
- array_reduce(progressListeners, function (undefined, progressListener) {
- Q.nextTick(function () {
- progressListener(progress);
- });
- }, void 0);
- };
-
- return deferred;
-}
-
-/**
- * Creates a Node-style callback that will resolve or reject the deferred
- * promise.
- * @returns a nodeback
- */
-defer.prototype.makeNodeResolver = function () {
- var self = this;
- return function (error, value) {
- if (error) {
- self.reject(error);
- } else if (arguments.length > 2) {
- self.resolve(array_slice(arguments, 1));
- } else {
- self.resolve(value);
- }
- };
-};
-
-/**
- * @param resolver {Function} a function that returns nothing and accepts
- * the resolve, reject, and notify functions for a deferred.
- * @returns a promise that may be resolved with the given resolve and reject
- * functions, or rejected by a thrown exception in resolver
- */
-Q.Promise = promise; // ES6
-Q.promise = promise;
-function promise(resolver) {
- if (typeof resolver !== "function") {
- throw new TypeError("resolver must be a function.");
- }
- var deferred = defer();
- try {
- resolver(deferred.resolve, deferred.reject, deferred.notify);
- } catch (reason) {
- deferred.reject(reason);
- }
- return deferred.promise;
-}
-
-promise.race = race; // ES6
-promise.all = all; // ES6
-promise.reject = reject; // ES6
-promise.resolve = Q; // ES6
-
-// XXX experimental. This method is a way to denote that a local value is
-// serializable and should be immediately dispatched to a remote upon request,
-// instead of passing a reference.
-Q.passByCopy = function (object) {
- //freeze(object);
- //passByCopies.set(object, true);
- return object;
-};
-
-Promise.prototype.passByCopy = function () {
- //freeze(object);
- //passByCopies.set(object, true);
- return this;
-};
-
-/**
- * If two promises eventually fulfill to the same value, promises that value,
- * but otherwise rejects.
- * @param x {Any*}
- * @param y {Any*}
- * @returns {Any*} a promise for x and y if they are the same, but a rejection
- * otherwise.
- *
- */
-Q.join = function (x, y) {
- return Q(x).join(y);
-};
-
-Promise.prototype.join = function (that) {
- return Q([this, that]).spread(function (x, y) {
- if (x === y) {
- // TODO: "===" should be Object.is or equiv
- return x;
- } else {
- throw new Error("Can't join: not the same: " + x + " " + y);
- }
- });
-};
-
-/**
- * Returns a promise for the first of an array of promises to become settled.
- * @param answers {Array[Any*]} promises to race
- * @returns {Any*} the first promise to be settled
- */
-Q.race = race;
-function race(answerPs) {
- return promise(function (resolve, reject) {
- // Switch to this once we can assume at least ES5
- // answerPs.forEach(function (answerP) {
- // Q(answerP).then(resolve, reject);
- // });
- // Use this in the meantime
- for (var i = 0, len = answerPs.length; i < len; i++) {
- Q(answerPs[i]).then(resolve, reject);
- }
- });
-}
-
-Promise.prototype.race = function () {
- return this.then(Q.race);
-};
-
-/**
- * Constructs a Promise with a promise descriptor object and optional fallback
- * function. The descriptor contains methods like when(rejected), get(name),
- * set(name, value), post(name, args), and delete(name), which all
- * return either a value, a promise for a value, or a rejection. The fallback
- * accepts the operation name, a resolver, and any further arguments that would
- * have been forwarded to the appropriate method above had a method been
- * provided with the proper name. The API makes no guarantees about the nature
- * of the returned object, apart from that it is usable whereever promises are
- * bought and sold.
- */
-Q.makePromise = Promise;
-function Promise(descriptor, fallback, inspect) {
- if (fallback === void 0) {
- fallback = function (op) {
- return reject(new Error(
- "Promise does not support operation: " + op
- ));
- };
- }
- if (inspect === void 0) {
- inspect = function () {
- return {state: "unknown"};
- };
- }
-
- var promise = object_create(Promise.prototype);
-
- promise.promiseDispatch = function (resolve, op, args) {
- var result;
- try {
- if (descriptor[op]) {
- result = descriptor[op].apply(promise, args);
- } else {
- result = fallback.call(promise, op, args);
- }
- } catch (exception) {
- result = reject(exception);
- }
- if (resolve) {
- resolve(result);
- }
- };
-
- promise.inspect = inspect;
-
- // XXX deprecated `valueOf` and `exception` support
- if (inspect) {
- var inspected = inspect();
- if (inspected.state === "rejected") {
- promise.exception = inspected.reason;
- }
-
- promise.valueOf = function () {
- var inspected = inspect();
- if (inspected.state === "pending" ||
- inspected.state === "rejected") {
- return promise;
- }
- return inspected.value;
- };
- }
-
- return promise;
-}
-
-Promise.prototype.toString = function () {
- return "[object Promise]";
-};
-
-Promise.prototype.then = function (fulfilled, rejected, progressed) {
- var self = this;
- var deferred = defer();
- var done = false; // ensure the untrusted promise makes at most a
- // single call to one of the callbacks
-
- function _fulfilled(value) {
- try {
- return typeof fulfilled === "function" ? fulfilled(value) : value;
- } catch (exception) {
- return reject(exception);
- }
- }
-
- function _rejected(exception) {
- if (typeof rejected === "function") {
- makeStackTraceLong(exception, self);
- try {
- return rejected(exception);
- } catch (newException) {
- return reject(newException);
- }
- }
- return reject(exception);
- }
-
- function _progressed(value) {
- return typeof progressed === "function" ? progressed(value) : value;
- }
-
- Q.nextTick(function () {
- self.promiseDispatch(function (value) {
- if (done) {
- return;
- }
- done = true;
-
- deferred.resolve(_fulfilled(value));
- }, "when", [function (exception) {
- if (done) {
- return;
- }
- done = true;
-
- deferred.resolve(_rejected(exception));
- }]);
- });
-
- // Progress propagator need to be attached in the current tick.
- self.promiseDispatch(void 0, "when", [void 0, function (value) {
- var newValue;
- var threw = false;
- try {
- newValue = _progressed(value);
- } catch (e) {
- threw = true;
- if (Q.onerror) {
- Q.onerror(e);
- } else {
- throw e;
- }
- }
-
- if (!threw) {
- deferred.notify(newValue);
- }
- }]);
-
- return deferred.promise;
-};
-
-Q.tap = function (promise, callback) {
- return Q(promise).tap(callback);
-};
-
-/**
- * Works almost like "finally", but not called for rejections.
- * Original resolution value is passed through callback unaffected.
- * Callback may return a promise that will be awaited for.
- * @param {Function} callback
- * @returns {Q.Promise}
- * @example
- * doSomething()
- * .then(...)
- * .tap(console.log)
- * .then(...);
- */
-Promise.prototype.tap = function (callback) {
- callback = Q(callback);
-
- return this.then(function (value) {
- return callback.fcall(value).thenResolve(value);
- });
-};
-
-/**
- * Registers an observer on a promise.
- *
- * Guarantees:
- *
- * 1. that fulfilled and rejected will be called only once.
- * 2. that either the fulfilled callback or the rejected callback will be
- * called, but not both.
- * 3. that fulfilled and rejected will not be called in this turn.
- *
- * @param value promise or immediate reference to observe
- * @param fulfilled function to be called with the fulfilled value
- * @param rejected function to be called with the rejection exception
- * @param progressed function to be called on any progress notifications
- * @return promise for the return value from the invoked callback
- */
-Q.when = when;
-function when(value, fulfilled, rejected, progressed) {
- return Q(value).then(fulfilled, rejected, progressed);
-}
-
-Promise.prototype.thenResolve = function (value) {
- return this.then(function () { return value; });
-};
-
-Q.thenResolve = function (promise, value) {
- return Q(promise).thenResolve(value);
-};
-
-Promise.prototype.thenReject = function (reason) {
- return this.then(function () { throw reason; });
-};
-
-Q.thenReject = function (promise, reason) {
- return Q(promise).thenReject(reason);
-};
-
-/**
- * If an object is not a promise, it is as "near" as possible.
- * If a promise is rejected, it is as "near" as possible too.
- * If it’s a fulfilled promise, the fulfillment value is nearer.
- * If it’s a deferred promise and the deferred has been resolved, the
- * resolution is "nearer".
- * @param object
- * @returns most resolved (nearest) form of the object
- */
-
-// XXX should we re-do this?
-Q.nearer = nearer;
-function nearer(value) {
- if (isPromise(value)) {
- var inspected = value.inspect();
- if (inspected.state === "fulfilled") {
- return inspected.value;
- }
- }
- return value;
-}
-
-/**
- * @returns whether the given object is a promise.
- * Otherwise it is a fulfilled value.
- */
-Q.isPromise = isPromise;
-function isPromise(object) {
- return object instanceof Promise;
-}
-
-Q.isPromiseAlike = isPromiseAlike;
-function isPromiseAlike(object) {
- return isObject(object) && typeof object.then === "function";
-}
-
-/**
- * @returns whether the given object is a pending promise, meaning not
- * fulfilled or rejected.
- */
-Q.isPending = isPending;
-function isPending(object) {
- return isPromise(object) && object.inspect().state === "pending";
-}
-
-Promise.prototype.isPending = function () {
- return this.inspect().state === "pending";
-};
-
-/**
- * @returns whether the given object is a value or fulfilled
- * promise.
- */
-Q.isFulfilled = isFulfilled;
-function isFulfilled(object) {
- return !isPromise(object) || object.inspect().state === "fulfilled";
-}
-
-Promise.prototype.isFulfilled = function () {
- return this.inspect().state === "fulfilled";
-};
-
-/**
- * @returns whether the given object is a rejected promise.
- */
-Q.isRejected = isRejected;
-function isRejected(object) {
- return isPromise(object) && object.inspect().state === "rejected";
-}
-
-Promise.prototype.isRejected = function () {
- return this.inspect().state === "rejected";
-};
-
-//// BEGIN UNHANDLED REJECTION TRACKING
-
-// This promise library consumes exceptions thrown in handlers so they can be
-// handled by a subsequent promise. The exceptions get added to this array when
-// they are created, and removed when they are handled. Note that in ES6 or
-// shimmed environments, this would naturally be a `Set`.
-var unhandledReasons = [];
-var unhandledRejections = [];
-var reportedUnhandledRejections = [];
-var trackUnhandledRejections = true;
-
-function resetUnhandledRejections() {
- unhandledReasons.length = 0;
- unhandledRejections.length = 0;
-
- if (!trackUnhandledRejections) {
- trackUnhandledRejections = true;
- }
-}
-
-function trackRejection(promise, reason) {
- if (!trackUnhandledRejections) {
- return;
- }
- if (typeof process === "object" && typeof process.emit === "function") {
- Q.nextTick.runAfter(function () {
- if (array_indexOf(unhandledRejections, promise) !== -1) {
- process.emit("unhandledRejection", reason, promise);
- reportedUnhandledRejections.push(promise);
- }
- });
- }
-
- unhandledRejections.push(promise);
- if (reason && typeof reason.stack !== "undefined") {
- unhandledReasons.push(reason.stack);
- } else {
- unhandledReasons.push("(no stack) " + reason);
- }
-}
-
-function untrackRejection(promise) {
- if (!trackUnhandledRejections) {
- return;
- }
-
- var at = array_indexOf(unhandledRejections, promise);
- if (at !== -1) {
- if (typeof process === "object" && typeof process.emit === "function") {
- Q.nextTick.runAfter(function () {
- var atReport = array_indexOf(reportedUnhandledRejections, promise);
- if (atReport !== -1) {
- process.emit("rejectionHandled", unhandledReasons[at], promise);
- reportedUnhandledRejections.splice(atReport, 1);
- }
- });
- }
- unhandledRejections.splice(at, 1);
- unhandledReasons.splice(at, 1);
- }
-}
-
-Q.resetUnhandledRejections = resetUnhandledRejections;
-
-Q.getUnhandledReasons = function () {
- // Make a copy so that consumers can't interfere with our internal state.
- return unhandledReasons.slice();
-};
-
-Q.stopUnhandledRejectionTracking = function () {
- resetUnhandledRejections();
- trackUnhandledRejections = false;
-};
-
-resetUnhandledRejections();
-
-//// END UNHANDLED REJECTION TRACKING
-
-/**
- * Constructs a rejected promise.
- * @param reason value describing the failure
- */
-Q.reject = reject;
-function reject(reason) {
- var rejection = Promise({
- "when": function (rejected) {
- // note that the error has been handled
- if (rejected) {
- untrackRejection(this);
- }
- return rejected ? rejected(reason) : this;
- }
- }, function fallback() {
- return this;
- }, function inspect() {
- return { state: "rejected", reason: reason };
- });
-
- // Note that the reason has not been handled.
- trackRejection(rejection, reason);
-
- return rejection;
-}
-
-/**
- * Constructs a fulfilled promise for an immediate reference.
- * @param value immediate reference
- */
-Q.fulfill = fulfill;
-function fulfill(value) {
- return Promise({
- "when": function () {
- return value;
- },
- "get": function (name) {
- return value[name];
- },
- "set": function (name, rhs) {
- value[name] = rhs;
- },
- "delete": function (name) {
- delete value[name];
- },
- "post": function (name, args) {
- // Mark Miller proposes that post with no name should apply a
- // promised function.
- if (name === null || name === void 0) {
- return value.apply(void 0, args);
- } else {
- return value[name].apply(value, args);
- }
- },
- "apply": function (thisp, args) {
- return value.apply(thisp, args);
- },
- "keys": function () {
- return object_keys(value);
- }
- }, void 0, function inspect() {
- return { state: "fulfilled", value: value };
- });
-}
-
-/**
- * Converts thenables to Q promises.
- * @param promise thenable promise
- * @returns a Q promise
- */
-function coerce(promise) {
- var deferred = defer();
- Q.nextTick(function () {
- try {
- promise.then(deferred.resolve, deferred.reject, deferred.notify);
- } catch (exception) {
- deferred.reject(exception);
- }
- });
- return deferred.promise;
-}
-
-/**
- * Annotates an object such that it will never be
- * transferred away from this process over any promise
- * communication channel.
- * @param object
- * @returns promise a wrapping of that object that
- * additionally responds to the "isDef" message
- * without a rejection.
- */
-Q.master = master;
-function master(object) {
- return Promise({
- "isDef": function () {}
- }, function fallback(op, args) {
- return dispatch(object, op, args);
- }, function () {
- return Q(object).inspect();
- });
-}
-
-/**
- * Spreads the values of a promised array of arguments into the
- * fulfillment callback.
- * @param fulfilled callback that receives variadic arguments from the
- * promised array
- * @param rejected callback that receives the exception if the promise
- * is rejected.
- * @returns a promise for the return value or thrown exception of
- * either callback.
- */
-Q.spread = spread;
-function spread(value, fulfilled, rejected) {
- return Q(value).spread(fulfilled, rejected);
-}
-
-Promise.prototype.spread = function (fulfilled, rejected) {
- return this.all().then(function (array) {
- return fulfilled.apply(void 0, array);
- }, rejected);
-};
-
-/**
- * The async function is a decorator for generator functions, turning
- * them into asynchronous generators. Although generators are only part
- * of the newest ECMAScript 6 drafts, this code does not cause syntax
- * errors in older engines. This code should continue to work and will
- * in fact improve over time as the language improves.
- *
- * ES6 generators are currently part of V8 version 3.19 with the
- * --harmony-generators runtime flag enabled. SpiderMonkey has had them
- * for longer, but under an older Python-inspired form. This function
- * works on both kinds of generators.
- *
- * Decorates a generator function such that:
- * - it may yield promises
- * - execution will continue when that promise is fulfilled
- * - the value of the yield expression will be the fulfilled value
- * - it returns a promise for the return value (when the generator
- * stops iterating)
- * - the decorated function returns a promise for the return value
- * of the generator or the first rejected promise among those
- * yielded.
- * - if an error is thrown in the generator, it propagates through
- * every following yield until it is caught, or until it escapes
- * the generator function altogether, and is translated into a
- * rejection for the promise returned by the decorated generator.
- */
-Q.async = async;
-function async(makeGenerator) {
- return function () {
- // when verb is "send", arg is a value
- // when verb is "throw", arg is an exception
- function continuer(verb, arg) {
- var result;
-
- // Until V8 3.19 / Chromium 29 is released, SpiderMonkey is the only
- // engine that has a deployed base of browsers that support generators.
- // However, SM's generators use the Python-inspired semantics of
- // outdated ES6 drafts. We would like to support ES6, but we'd also
- // like to make it possible to use generators in deployed browsers, so
- // we also support Python-style generators. At some point we can remove
- // this block.
-
- if (typeof StopIteration === "undefined") {
- // ES6 Generators
- try {
- result = generator[verb](arg);
- } catch (exception) {
- return reject(exception);
- }
- if (result.done) {
- return Q(result.value);
- } else {
- return when(result.value, callback, errback);
- }
- } else {
- // SpiderMonkey Generators
- // FIXME: Remove this case when SM does ES6 generators.
- try {
- result = generator[verb](arg);
- } catch (exception) {
- if (isStopIteration(exception)) {
- return Q(exception.value);
- } else {
- return reject(exception);
- }
- }
- return when(result, callback, errback);
- }
- }
- var generator = makeGenerator.apply(this, arguments);
- var callback = continuer.bind(continuer, "next");
- var errback = continuer.bind(continuer, "throw");
- return callback();
- };
-}
-
-/**
- * The spawn function is a small wrapper around async that immediately
- * calls the generator and also ends the promise chain, so that any
- * unhandled errors are thrown instead of forwarded to the error
- * handler. This is useful because it's extremely common to run
- * generators at the top-level to work with libraries.
- */
-Q.spawn = spawn;
-function spawn(makeGenerator) {
- Q.done(Q.async(makeGenerator)());
-}
-
-// FIXME: Remove this interface once ES6 generators are in SpiderMonkey.
-/**
- * Throws a ReturnValue exception to stop an asynchronous generator.
- *
- * This interface is a stop-gap measure to support generator return
- * values in older Firefox/SpiderMonkey. In browsers that support ES6
- * generators like Chromium 29, just use "return" in your generator
- * functions.
- *
- * @param value the return value for the surrounding generator
- * @throws ReturnValue exception with the value.
- * @example
- * // ES6 style
- * Q.async(function* () {
- * var foo = yield getFooPromise();
- * var bar = yield getBarPromise();
- * return foo + bar;
- * })
- * // Older SpiderMonkey style
- * Q.async(function () {
- * var foo = yield getFooPromise();
- * var bar = yield getBarPromise();
- * Q.return(foo + bar);
- * })
- */
-Q["return"] = _return;
-function _return(value) {
- throw new QReturnValue(value);
-}
-
-/**
- * The promised function decorator ensures that any promise arguments
- * are settled and passed as values (`this` is also settled and passed
- * as a value). It will also ensure that the result of a function is
- * always a promise.
- *
- * @example
- * var add = Q.promised(function (a, b) {
- * return a + b;
- * });
- * add(Q(a), Q(B));
- *
- * @param {function} callback The function to decorate
- * @returns {function} a function that has been decorated.
- */
-Q.promised = promised;
-function promised(callback) {
- return function () {
- return spread([this, all(arguments)], function (self, args) {
- return callback.apply(self, args);
- });
- };
-}
-
-/**
- * sends a message to a value in a future turn
- * @param object* the recipient
- * @param op the name of the message operation, e.g., "when",
- * @param args further arguments to be forwarded to the operation
- * @returns result {Promise} a promise for the result of the operation
- */
-Q.dispatch = dispatch;
-function dispatch(object, op, args) {
- return Q(object).dispatch(op, args);
-}
-
-Promise.prototype.dispatch = function (op, args) {
- var self = this;
- var deferred = defer();
- Q.nextTick(function () {
- self.promiseDispatch(deferred.resolve, op, args);
- });
- return deferred.promise;
-};
-
-/**
- * Gets the value of a property in a future turn.
- * @param object promise or immediate reference for target object
- * @param name name of property to get
- * @return promise for the property value
- */
-Q.get = function (object, key) {
- return Q(object).dispatch("get", [key]);
-};
-
-Promise.prototype.get = function (key) {
- return this.dispatch("get", [key]);
-};
-
-/**
- * Sets the value of a property in a future turn.
- * @param object promise or immediate reference for object object
- * @param name name of property to set
- * @param value new value of property
- * @return promise for the return value
- */
-Q.set = function (object, key, value) {
- return Q(object).dispatch("set", [key, value]);
-};
-
-Promise.prototype.set = function (key, value) {
- return this.dispatch("set", [key, value]);
-};
-
-/**
- * Deletes a property in a future turn.
- * @param object promise or immediate reference for target object
- * @param name name of property to delete
- * @return promise for the return value
- */
-Q.del = // XXX legacy
-Q["delete"] = function (object, key) {
- return Q(object).dispatch("delete", [key]);
-};
-
-Promise.prototype.del = // XXX legacy
-Promise.prototype["delete"] = function (key) {
- return this.dispatch("delete", [key]);
-};
-
-/**
- * Invokes a method in a future turn.
- * @param object promise or immediate reference for target object
- * @param name name of method to invoke
- * @param value a value to post, typically an array of
- * invocation arguments for promises that
- * are ultimately backed with `resolve` values,
- * as opposed to those backed with URLs
- * wherein the posted value can be any
- * JSON serializable object.
- * @return promise for the return value
- */
-// bound locally because it is used by other methods
-Q.mapply = // XXX As proposed by "Redsandro"
-Q.post = function (object, name, args) {
- return Q(object).dispatch("post", [name, args]);
-};
-
-Promise.prototype.mapply = // XXX As proposed by "Redsandro"
-Promise.prototype.post = function (name, args) {
- return this.dispatch("post", [name, args]);
-};
-
-/**
- * Invokes a method in a future turn.
- * @param object promise or immediate reference for target object
- * @param name name of method to invoke
- * @param ...args array of invocation arguments
- * @return promise for the return value
- */
-Q.send = // XXX Mark Miller's proposed parlance
-Q.mcall = // XXX As proposed by "Redsandro"
-Q.invoke = function (object, name /*...args*/) {
- return Q(object).dispatch("post", [name, array_slice(arguments, 2)]);
-};
-
-Promise.prototype.send = // XXX Mark Miller's proposed parlance
-Promise.prototype.mcall = // XXX As proposed by "Redsandro"
-Promise.prototype.invoke = function (name /*...args*/) {
- return this.dispatch("post", [name, array_slice(arguments, 1)]);
-};
-
-/**
- * Applies the promised function in a future turn.
- * @param object promise or immediate reference for target function
- * @param args array of application arguments
- */
-Q.fapply = function (object, args) {
- return Q(object).dispatch("apply", [void 0, args]);
-};
-
-Promise.prototype.fapply = function (args) {
- return this.dispatch("apply", [void 0, args]);
-};
-
-/**
- * Calls the promised function in a future turn.
- * @param object promise or immediate reference for target function
- * @param ...args array of application arguments
- */
-Q["try"] =
-Q.fcall = function (object /* ...args*/) {
- return Q(object).dispatch("apply", [void 0, array_slice(arguments, 1)]);
-};
-
-Promise.prototype.fcall = function (/*...args*/) {
- return this.dispatch("apply", [void 0, array_slice(arguments)]);
-};
-
-/**
- * Binds the promised function, transforming return values into a fulfilled
- * promise and thrown errors into a rejected one.
- * @param object promise or immediate reference for target function
- * @param ...args array of application arguments
- */
-Q.fbind = function (object /*...args*/) {
- var promise = Q(object);
- var args = array_slice(arguments, 1);
- return function fbound() {
- return promise.dispatch("apply", [
- this,
- args.concat(array_slice(arguments))
- ]);
- };
-};
-Promise.prototype.fbind = function (/*...args*/) {
- var promise = this;
- var args = array_slice(arguments);
- return function fbound() {
- return promise.dispatch("apply", [
- this,
- args.concat(array_slice(arguments))
- ]);
- };
-};
-
-/**
- * Requests the names of the owned properties of a promised
- * object in a future turn.
- * @param object promise or immediate reference for target object
- * @return promise for the keys of the eventually settled object
- */
-Q.keys = function (object) {
- return Q(object).dispatch("keys", []);
-};
-
-Promise.prototype.keys = function () {
- return this.dispatch("keys", []);
-};
-
-/**
- * Turns an array of promises into a promise for an array. If any of
- * the promises gets rejected, the whole array is rejected immediately.
- * @param {Array*} an array (or promise for an array) of values (or
- * promises for values)
- * @returns a promise for an array of the corresponding values
- */
-// By Mark Miller
-// http://wiki.ecmascript.org/doku.php?id=strawman:concurrency&rev=1308776521#allfulfilled
-Q.all = all;
-function all(promises) {
- return when(promises, function (promises) {
- var pendingCount = 0;
- var deferred = defer();
- array_reduce(promises, function (undefined, promise, index) {
- var snapshot;
- if (
- isPromise(promise) &&
- (snapshot = promise.inspect()).state === "fulfilled"
- ) {
- promises[index] = snapshot.value;
- } else {
- ++pendingCount;
- when(
- promise,
- function (value) {
- promises[index] = value;
- if (--pendingCount === 0) {
- deferred.resolve(promises);
- }
- },
- deferred.reject,
- function (progress) {
- deferred.notify({ index: index, value: progress });
- }
- );
- }
- }, void 0);
- if (pendingCount === 0) {
- deferred.resolve(promises);
- }
- return deferred.promise;
- });
-}
-
-Promise.prototype.all = function () {
- return all(this);
-};
-
-/**
- * Returns the first resolved promise of an array. Prior rejected promises are
- * ignored. Rejects only if all promises are rejected.
- * @param {Array*} an array containing values or promises for values
- * @returns a promise fulfilled with the value of the first resolved promise,
- * or a rejected promise if all promises are rejected.
- */
-Q.any = any;
-
-function any(promises) {
- if (promises.length === 0) {
- return Q.resolve();
- }
-
- var deferred = Q.defer();
- var pendingCount = 0;
- array_reduce(promises, function (prev, current, index) {
- var promise = promises[index];
-
- pendingCount++;
-
- when(promise, onFulfilled, onRejected, onProgress);
- function onFulfilled(result) {
- deferred.resolve(result);
- }
- function onRejected() {
- pendingCount--;
- if (pendingCount === 0) {
- deferred.reject(new Error(
- "Can't get fulfillment value from any promise, all " +
- "promises were rejected."
- ));
- }
- }
- function onProgress(progress) {
- deferred.notify({
- index: index,
- value: progress
- });
- }
- }, undefined);
-
- return deferred.promise;
-}
-
-Promise.prototype.any = function () {
- return any(this);
-};
-
-/**
- * Waits for all promises to be settled, either fulfilled or
- * rejected. This is distinct from `all` since that would stop
- * waiting at the first rejection. The promise returned by
- * `allResolved` will never be rejected.
- * @param promises a promise for an array (or an array) of promises
- * (or values)
- * @return a promise for an array of promises
- */
-Q.allResolved = deprecate(allResolved, "allResolved", "allSettled");
-function allResolved(promises) {
- return when(promises, function (promises) {
- promises = array_map(promises, Q);
- return when(all(array_map(promises, function (promise) {
- return when(promise, noop, noop);
- })), function () {
- return promises;
- });
- });
-}
-
-Promise.prototype.allResolved = function () {
- return allResolved(this);
-};
-
-/**
- * @see Promise#allSettled
- */
-Q.allSettled = allSettled;
-function allSettled(promises) {
- return Q(promises).allSettled();
-}
-
-/**
- * Turns an array of promises into a promise for an array of their states (as
- * returned by `inspect`) when they have all settled.
- * @param {Array[Any*]} values an array (or promise for an array) of values (or
- * promises for values)
- * @returns {Array[State]} an array of states for the respective values.
- */
-Promise.prototype.allSettled = function () {
- return this.then(function (promises) {
- return all(array_map(promises, function (promise) {
- promise = Q(promise);
- function regardless() {
- return promise.inspect();
- }
- return promise.then(regardless, regardless);
- }));
- });
-};
-
-/**
- * Captures the failure of a promise, giving an oportunity to recover
- * with a callback. If the given promise is fulfilled, the returned
- * promise is fulfilled.
- * @param {Any*} promise for something
- * @param {Function} callback to fulfill the returned promise if the
- * given promise is rejected
- * @returns a promise for the return value of the callback
- */
-Q.fail = // XXX legacy
-Q["catch"] = function (object, rejected) {
- return Q(object).then(void 0, rejected);
-};
-
-Promise.prototype.fail = // XXX legacy
-Promise.prototype["catch"] = function (rejected) {
- return this.then(void 0, rejected);
-};
-
-/**
- * Attaches a listener that can respond to progress notifications from a
- * promise's originating deferred. This listener receives the exact arguments
- * passed to ``deferred.notify``.
- * @param {Any*} promise for something
- * @param {Function} callback to receive any progress notifications
- * @returns the given promise, unchanged
- */
-Q.progress = progress;
-function progress(object, progressed) {
- return Q(object).then(void 0, void 0, progressed);
-}
-
-Promise.prototype.progress = function (progressed) {
- return this.then(void 0, void 0, progressed);
-};
-
-/**
- * Provides an opportunity to observe the settling of a promise,
- * regardless of whether the promise is fulfilled or rejected. Forwards
- * the resolution to the returned promise when the callback is done.
- * The callback can return a promise to defer completion.
- * @param {Any*} promise
- * @param {Function} callback to observe the resolution of the given
- * promise, takes no arguments.
- * @returns a promise for the resolution of the given promise when
- * ``fin`` is done.
- */
-Q.fin = // XXX legacy
-Q["finally"] = function (object, callback) {
- return Q(object)["finally"](callback);
-};
-
-Promise.prototype.fin = // XXX legacy
-Promise.prototype["finally"] = function (callback) {
- callback = Q(callback);
- return this.then(function (value) {
- return callback.fcall().then(function () {
- return value;
- });
- }, function (reason) {
- // TODO attempt to recycle the rejection with "this".
- return callback.fcall().then(function () {
- throw reason;
- });
- });
-};
-
-/**
- * Terminates a chain of promises, forcing rejections to be
- * thrown as exceptions.
- * @param {Any*} promise at the end of a chain of promises
- * @returns nothing
- */
-Q.done = function (object, fulfilled, rejected, progress) {
- return Q(object).done(fulfilled, rejected, progress);
-};
-
-Promise.prototype.done = function (fulfilled, rejected, progress) {
- var onUnhandledError = function (error) {
- // forward to a future turn so that ``when``
- // does not catch it and turn it into a rejection.
- Q.nextTick(function () {
- makeStackTraceLong(error, promise);
- if (Q.onerror) {
- Q.onerror(error);
- } else {
- throw error;
- }
- });
- };
-
- // Avoid unnecessary `nextTick`ing via an unnecessary `when`.
- var promise = fulfilled || rejected || progress ?
- this.then(fulfilled, rejected, progress) :
- this;
-
- if (typeof process === "object" && process && process.domain) {
- onUnhandledError = process.domain.bind(onUnhandledError);
- }
-
- promise.then(void 0, onUnhandledError);
-};
-
-/**
- * Causes a promise to be rejected if it does not get fulfilled before
- * some milliseconds time out.
- * @param {Any*} promise
- * @param {Number} milliseconds timeout
- * @param {Any*} custom error message or Error object (optional)
- * @returns a promise for the resolution of the given promise if it is
- * fulfilled before the timeout, otherwise rejected.
- */
-Q.timeout = function (object, ms, error) {
- return Q(object).timeout(ms, error);
-};
-
-Promise.prototype.timeout = function (ms, error) {
- var deferred = defer();
- var timeoutId = setTimeout(function () {
- if (!error || "string" === typeof error) {
- error = new Error(error || "Timed out after " + ms + " ms");
- error.code = "ETIMEDOUT";
- }
- deferred.reject(error);
- }, ms);
-
- this.then(function (value) {
- clearTimeout(timeoutId);
- deferred.resolve(value);
- }, function (exception) {
- clearTimeout(timeoutId);
- deferred.reject(exception);
- }, deferred.notify);
-
- return deferred.promise;
-};
-
-/**
- * Returns a promise for the given value (or promised value), some
- * milliseconds after it resolved. Passes rejections immediately.
- * @param {Any*} promise
- * @param {Number} milliseconds
- * @returns a promise for the resolution of the given promise after milliseconds
- * time has elapsed since the resolution of the given promise.
- * If the given promise rejects, that is passed immediately.
- */
-Q.delay = function (object, timeout) {
- if (timeout === void 0) {
- timeout = object;
- object = void 0;
- }
- return Q(object).delay(timeout);
-};
-
-Promise.prototype.delay = function (timeout) {
- return this.then(function (value) {
- var deferred = defer();
- setTimeout(function () {
- deferred.resolve(value);
- }, timeout);
- return deferred.promise;
- });
-};
-
-/**
- * Passes a continuation to a Node function, which is called with the given
- * arguments provided as an array, and returns a promise.
- *
- * Q.nfapply(FS.readFile, [__filename])
- * .then(function (content) {
- * })
- *
- */
-Q.nfapply = function (callback, args) {
- return Q(callback).nfapply(args);
-};
-
-Promise.prototype.nfapply = function (args) {
- var deferred = defer();
- var nodeArgs = array_slice(args);
- nodeArgs.push(deferred.makeNodeResolver());
- this.fapply(nodeArgs).fail(deferred.reject);
- return deferred.promise;
-};
-
-/**
- * Passes a continuation to a Node function, which is called with the given
- * arguments provided individually, and returns a promise.
- * @example
- * Q.nfcall(FS.readFile, __filename)
- * .then(function (content) {
- * })
- *
- */
-Q.nfcall = function (callback /*...args*/) {
- var args = array_slice(arguments, 1);
- return Q(callback).nfapply(args);
-};
-
-Promise.prototype.nfcall = function (/*...args*/) {
- var nodeArgs = array_slice(arguments);
- var deferred = defer();
- nodeArgs.push(deferred.makeNodeResolver());
- this.fapply(nodeArgs).fail(deferred.reject);
- return deferred.promise;
-};
-
-/**
- * Wraps a NodeJS continuation passing function and returns an equivalent
- * version that returns a promise.
- * @example
- * Q.nfbind(FS.readFile, __filename)("utf-8")
- * .then(console.log)
- * .done()
- */
-Q.nfbind =
-Q.denodeify = function (callback /*...args*/) {
- var baseArgs = array_slice(arguments, 1);
- return function () {
- var nodeArgs = baseArgs.concat(array_slice(arguments));
- var deferred = defer();
- nodeArgs.push(deferred.makeNodeResolver());
- Q(callback).fapply(nodeArgs).fail(deferred.reject);
- return deferred.promise;
- };
-};
-
-Promise.prototype.nfbind =
-Promise.prototype.denodeify = function (/*...args*/) {
- var args = array_slice(arguments);
- args.unshift(this);
- return Q.denodeify.apply(void 0, args);
-};
-
-Q.nbind = function (callback, thisp /*...args*/) {
- var baseArgs = array_slice(arguments, 2);
- return function () {
- var nodeArgs = baseArgs.concat(array_slice(arguments));
- var deferred = defer();
- nodeArgs.push(deferred.makeNodeResolver());
- function bound() {
- return callback.apply(thisp, arguments);
- }
- Q(bound).fapply(nodeArgs).fail(deferred.reject);
- return deferred.promise;
- };
-};
-
-Promise.prototype.nbind = function (/*thisp, ...args*/) {
- var args = array_slice(arguments, 0);
- args.unshift(this);
- return Q.nbind.apply(void 0, args);
-};
-
-/**
- * Calls a method of a Node-style object that accepts a Node-style
- * callback with a given array of arguments, plus a provided callback.
- * @param object an object that has the named method
- * @param {String} name name of the method of object
- * @param {Array} args arguments to pass to the method; the callback
- * will be provided by Q and appended to these arguments.
- * @returns a promise for the value or error
- */
-Q.nmapply = // XXX As proposed by "Redsandro"
-Q.npost = function (object, name, args) {
- return Q(object).npost(name, args);
-};
-
-Promise.prototype.nmapply = // XXX As proposed by "Redsandro"
-Promise.prototype.npost = function (name, args) {
- var nodeArgs = array_slice(args || []);
- var deferred = defer();
- nodeArgs.push(deferred.makeNodeResolver());
- this.dispatch("post", [name, nodeArgs]).fail(deferred.reject);
- return deferred.promise;
-};
-
-/**
- * Calls a method of a Node-style object that accepts a Node-style
- * callback, forwarding the given variadic arguments, plus a provided
- * callback argument.
- * @param object an object that has the named method
- * @param {String} name name of the method of object
- * @param ...args arguments to pass to the method; the callback will
- * be provided by Q and appended to these arguments.
- * @returns a promise for the value or error
- */
-Q.nsend = // XXX Based on Mark Miller's proposed "send"
-Q.nmcall = // XXX Based on "Redsandro's" proposal
-Q.ninvoke = function (object, name /*...args*/) {
- var nodeArgs = array_slice(arguments, 2);
- var deferred = defer();
- nodeArgs.push(deferred.makeNodeResolver());
- Q(object).dispatch("post", [name, nodeArgs]).fail(deferred.reject);
- return deferred.promise;
-};
-
-Promise.prototype.nsend = // XXX Based on Mark Miller's proposed "send"
-Promise.prototype.nmcall = // XXX Based on "Redsandro's" proposal
-Promise.prototype.ninvoke = function (name /*...args*/) {
- var nodeArgs = array_slice(arguments, 1);
- var deferred = defer();
- nodeArgs.push(deferred.makeNodeResolver());
- this.dispatch("post", [name, nodeArgs]).fail(deferred.reject);
- return deferred.promise;
-};
-
-/**
- * If a function would like to support both Node continuation-passing-style and
- * promise-returning-style, it can end its internal promise chain with
- * `nodeify(nodeback)`, forwarding the optional nodeback argument. If the user
- * elects to use a nodeback, the result will be sent there. If they do not
- * pass a nodeback, they will receive the result promise.
- * @param object a result (or a promise for a result)
- * @param {Function} nodeback a Node.js-style callback
- * @returns either the promise or nothing
- */
-Q.nodeify = nodeify;
-function nodeify(object, nodeback) {
- return Q(object).nodeify(nodeback);
-}
-
-Promise.prototype.nodeify = function (nodeback) {
- if (nodeback) {
- this.then(function (value) {
- Q.nextTick(function () {
- nodeback(null, value);
- });
- }, function (error) {
- Q.nextTick(function () {
- nodeback(error);
- });
- });
- } else {
- return this;
- }
-};
-
-Q.noConflict = function() {
- throw new Error("Q.noConflict only works when Q is used as a global");
-};
-
-// All code before this point will be filtered from stack traces.
-var qEndingLine = captureLine();
-
-return Q;
-
-});
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/adfd7874/node_modules/q/queue.js
----------------------------------------------------------------------
diff --git a/node_modules/q/queue.js b/node_modules/q/queue.js
deleted file mode 100644
index 1505fd0..0000000
--- a/node_modules/q/queue.js
+++ /dev/null
@@ -1,35 +0,0 @@
-
-var Q = require("./q");
-
-module.exports = Queue;
-function Queue() {
- var ends = Q.defer();
- var closed = Q.defer();
- return {
- put: function (value) {
- var next = Q.defer();
- ends.resolve({
- head: value,
- tail: next.promise
- });
- ends.resolve = next.resolve;
- },
- get: function () {
- var result = ends.promise.get("head");
- ends.promise = ends.promise.get("tail");
- return result.fail(function (error) {
- closed.resolve(error);
- throw error;
- });
- },
- closed: closed.promise,
- close: function (error) {
- error = error || new Error("Can't get value from closed queue");
- var end = {head: Q.reject(error)};
- end.tail = end;
- ends.resolve(end);
- return closed.promise;
- }
- };
-}
-
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[13/25] cordova-browser git commit: update shelljs version,
prepare is working
Posted by pu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/build/output.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/build/output.js b/node_modules/shelljs/build/output.js
deleted file mode 100644
index 1b778b9..0000000
--- a/node_modules/shelljs/build/output.js
+++ /dev/null
@@ -1,2411 +0,0 @@
-var common = require('./common');
-var fs = require('fs');
-
-//@
-//@ ### cat(file [, file ...])
-//@ ### cat(file_array)
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ var str = cat('file*.txt');
-//@ var str = cat('file1', 'file2');
-//@ var str = cat(['file1', 'file2']); // same as above
-//@ ```
-//@
-//@ Returns a string containing the given file, or a concatenated string
-//@ containing the files if more than one file is given (a new line character is
-//@ introduced between each file). Wildcard `*` accepted.
-function _cat(options, files) {
- var cat = '';
-
- if (!files)
- common.error('no paths given');
-
- if (typeof files === 'string')
- files = [].slice.call(arguments, 1);
- // if it's array leave it as it is
-
- files = common.expand(files);
-
- files.forEach(function(file) {
- if (!fs.existsSync(file))
- common.error('no such file or directory: ' + file);
-
- cat += fs.readFileSync(file, 'utf8');
- });
-
- return common.ShellString(cat);
-}
-module.exports = _cat;
-
-var fs = require('fs');
-var common = require('./common');
-
-//@
-//@ ### cd([dir])
-//@ Changes to directory `dir` for the duration of the script. Changes to home
-//@ directory if no argument is supplied.
-function _cd(options, dir) {
- if (!dir)
- dir = common.getUserHome();
-
- if (dir === '-') {
- if (!common.state.previousDir)
- common.error('could not find previous directory');
- else
- dir = common.state.previousDir;
- }
-
- if (!fs.existsSync(dir))
- common.error('no such file or directory: ' + dir);
-
- if (!fs.statSync(dir).isDirectory())
- common.error('not a directory: ' + dir);
-
- common.state.previousDir = process.cwd();
- process.chdir(dir);
-}
-module.exports = _cd;
-
-var common = require('./common');
-var fs = require('fs');
-var path = require('path');
-
-var PERMS = (function (base) {
- return {
- OTHER_EXEC : base.EXEC,
- OTHER_WRITE : base.WRITE,
- OTHER_READ : base.READ,
-
- GROUP_EXEC : base.EXEC << 3,
- GROUP_WRITE : base.WRITE << 3,
- GROUP_READ : base.READ << 3,
-
- OWNER_EXEC : base.EXEC << 6,
- OWNER_WRITE : base.WRITE << 6,
- OWNER_READ : base.READ << 6,
-
- // Literal octal numbers are apparently not allowed in "strict" javascript. Using parseInt is
- // the preferred way, else a jshint warning is thrown.
- STICKY : parseInt('01000', 8),
- SETGID : parseInt('02000', 8),
- SETUID : parseInt('04000', 8),
-
- TYPE_MASK : parseInt('0770000', 8)
- };
-})({
- EXEC : 1,
- WRITE : 2,
- READ : 4
-});
-
-//@
-//@ ### chmod(octal_mode || octal_string, file)
-//@ ### chmod(symbolic_mode, file)
-//@
-//@ Available options:
-//@
-//@ + `-v`: output a diagnostic for every file processed//@
-//@ + `-c`: like verbose but report only when a change is made//@
-//@ + `-R`: change files and directories recursively//@
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ chmod(755, '/Users/brandon');
-//@ chmod('755', '/Users/brandon'); // same as above
-//@ chmod('u+x', '/Users/brandon');
-//@ ```
-//@
-//@ Alters the permissions of a file or directory by either specifying the
-//@ absolute permissions in octal form or expressing the changes in symbols.
-//@ This command tries to mimic the POSIX behavior as much as possible.
-//@ Notable exceptions:
-//@
-//@ + In symbolic modes, 'a-r' and '-r' are identical. No consideration is
-//@ given to the umask.
-//@ + There is no "quiet" option since default behavior is to run silent.
-function _chmod(options, mode, filePattern) {
- if (!filePattern) {
- if (options.length > 0 && options.charAt(0) === '-') {
- // Special case where the specified file permissions started with - to subtract perms, which
- // get picked up by the option parser as command flags.
- // If we are down by one argument and options starts with -, shift everything over.
- filePattern = mode;
- mode = options;
- options = '';
- }
- else {
- common.error('You must specify a file.');
- }
- }
-
- options = common.parseOptions(options, {
- 'R': 'recursive',
- 'c': 'changes',
- 'v': 'verbose'
- });
-
- if (typeof filePattern === 'string') {
- filePattern = [ filePattern ];
- }
-
- var files;
-
- if (options.recursive) {
- files = [];
- common.expand(filePattern).forEach(function addFile(expandedFile) {
- var stat = fs.lstatSync(expandedFile);
-
- if (!stat.isSymbolicLink()) {
- files.push(expandedFile);
-
- if (stat.isDirectory()) { // intentionally does not follow symlinks.
- fs.readdirSync(expandedFile).forEach(function (child) {
- addFile(expandedFile + '/' + child);
- });
- }
- }
- });
- }
- else {
- files = common.expand(filePattern);
- }
-
- files.forEach(function innerChmod(file) {
- file = path.resolve(file);
- if (!fs.existsSync(file)) {
- common.error('File not found: ' + file);
- }
-
- // When recursing, don't follow symlinks.
- if (options.recursive && fs.lstatSync(file).isSymbolicLink()) {
- return;
- }
-
- var stat = fs.statSync(file);
- var isDir = stat.isDirectory();
- var perms = stat.mode;
- var type = perms & PERMS.TYPE_MASK;
-
- var newPerms = perms;
-
- if (isNaN(parseInt(mode, 8))) {
- // parse options
- mode.split(',').forEach(function (symbolicMode) {
- /*jshint regexdash:true */
- var pattern = /([ugoa]*)([=\+-])([rwxXst]*)/i;
- var matches = pattern.exec(symbolicMode);
-
- if (matches) {
- var applyTo = matches[1];
- var operator = matches[2];
- var change = matches[3];
-
- var changeOwner = applyTo.indexOf('u') != -1 || applyTo === 'a' || applyTo === '';
- var changeGroup = applyTo.indexOf('g') != -1 || applyTo === 'a' || applyTo === '';
- var changeOther = applyTo.indexOf('o') != -1 || applyTo === 'a' || applyTo === '';
-
- var changeRead = change.indexOf('r') != -1;
- var changeWrite = change.indexOf('w') != -1;
- var changeExec = change.indexOf('x') != -1;
- var changeExecDir = change.indexOf('X') != -1;
- var changeSticky = change.indexOf('t') != -1;
- var changeSetuid = change.indexOf('s') != -1;
-
- if (changeExecDir && isDir)
- changeExec = true;
-
- var mask = 0;
- if (changeOwner) {
- mask |= (changeRead ? PERMS.OWNER_READ : 0) + (changeWrite ? PERMS.OWNER_WRITE : 0) + (changeExec ? PERMS.OWNER_EXEC : 0) + (changeSetuid ? PERMS.SETUID : 0);
- }
- if (changeGroup) {
- mask |= (changeRead ? PERMS.GROUP_READ : 0) + (changeWrite ? PERMS.GROUP_WRITE : 0) + (changeExec ? PERMS.GROUP_EXEC : 0) + (changeSetuid ? PERMS.SETGID : 0);
- }
- if (changeOther) {
- mask |= (changeRead ? PERMS.OTHER_READ : 0) + (changeWrite ? PERMS.OTHER_WRITE : 0) + (changeExec ? PERMS.OTHER_EXEC : 0);
- }
-
- // Sticky bit is special - it's not tied to user, group or other.
- if (changeSticky) {
- mask |= PERMS.STICKY;
- }
-
- switch (operator) {
- case '+':
- newPerms |= mask;
- break;
-
- case '-':
- newPerms &= ~mask;
- break;
-
- case '=':
- newPerms = type + mask;
-
- // According to POSIX, when using = to explicitly set the permissions, setuid and setgid can never be cleared.
- if (fs.statSync(file).isDirectory()) {
- newPerms |= (PERMS.SETUID + PERMS.SETGID) & perms;
- }
- break;
- }
-
- if (options.verbose) {
- console.log(file + ' -> ' + newPerms.toString(8));
- }
-
- if (perms != newPerms) {
- if (!options.verbose && options.changes) {
- console.log(file + ' -> ' + newPerms.toString(8));
- }
- fs.chmodSync(file, newPerms);
- perms = newPerms; // for the next round of changes!
- }
- }
- else {
- common.error('Invalid symbolic mode change: ' + symbolicMode);
- }
- });
- }
- else {
- // they gave us a full number
- newPerms = type + parseInt(mode, 8);
-
- // POSIX rules are that setuid and setgid can only be added using numeric form, but not cleared.
- if (fs.statSync(file).isDirectory()) {
- newPerms |= (PERMS.SETUID + PERMS.SETGID) & perms;
- }
-
- fs.chmodSync(file, newPerms);
- }
- });
-}
-module.exports = _chmod;
-
-var os = require('os');
-var fs = require('fs');
-var _ls = require('./ls');
-
-// Module globals
-var config = {
- silent: false,
- fatal: false,
- verbose: false,
-};
-exports.config = config;
-
-var state = {
- error: null,
- currentCmd: 'shell.js',
- previousDir: null,
- tempDir: null
-};
-exports.state = state;
-
-var platform = os.type().match(/^Win/) ? 'win' : 'unix';
-exports.platform = platform;
-
-function log() {
- if (!config.silent)
- console.error.apply(console, arguments);
-}
-exports.log = log;
-
-// Shows error message. Throws unless _continue or config.fatal are true
-function error(msg, _continue) {
- if (state.error === null)
- state.error = '';
- var log_entry = state.currentCmd + ': ' + msg;
- if (state.error === '')
- state.error = log_entry;
- else
- state.error += '\n' + log_entry;
-
- if (msg.length > 0)
- log(log_entry);
-
- if (config.fatal)
- process.exit(1);
-
- if (!_continue)
- throw '';
-}
-exports.error = error;
-
-// In the future, when Proxies are default, we can add methods like `.to()` to primitive strings.
-// For now, this is a dummy function to bookmark places we need such strings
-function ShellString(str) {
- return str;
-}
-exports.ShellString = ShellString;
-
-// Return the home directory in a platform-agnostic way, with consideration for
-// older versions of node
-function getUserHome() {
- var result;
- if (os.homedir)
- result = os.homedir(); // node 3+
- else
- result = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'];
- return result;
-}
-exports.getUserHome = getUserHome;
-
-// Returns {'alice': true, 'bob': false} when passed a dictionary, e.g.:
-// parseOptions('-a', {'a':'alice', 'b':'bob'});
-function parseOptions(str, map) {
- if (!map)
- error('parseOptions() internal error: no map given');
-
- // All options are false by default
- var options = {};
- for (var letter in map) {
- if (!map[letter].match('^!'))
- options[map[letter]] = false;
- }
-
- if (!str)
- return options; // defaults
-
- if (typeof str !== 'string')
- error('parseOptions() internal error: wrong str');
-
- // e.g. match[1] = 'Rf' for str = '-Rf'
- var match = str.match(/^\-(.+)/);
- if (!match)
- return options;
-
- // e.g. chars = ['R', 'f']
- var chars = match[1].split('');
-
- var opt;
- chars.forEach(function(c) {
- if (c in map) {
- opt = map[c];
- if (opt.match('^!'))
- options[opt.slice(1, opt.length-1)] = false;
- else
- options[opt] = true;
- } else {
- error('option not recognized: '+c);
- }
- });
-
- return options;
-}
-exports.parseOptions = parseOptions;
-
-// Expands wildcards with matching (ie. existing) file names.
-// For example:
-// expand(['file*.js']) = ['file1.js', 'file2.js', ...]
-// (if the files 'file1.js', 'file2.js', etc, exist in the current dir)
-function expand(list) {
- var expanded = [];
- list.forEach(function(listEl) {
- // Wildcard present on directory names ?
- if(listEl.search(/\*[^\/]*\//) > -1 || listEl.search(/\*\*[^\/]*\//) > -1) {
- var match = listEl.match(/^([^*]+\/|)(.*)/);
- var root = match[1];
- var rest = match[2];
- var restRegex = rest.replace(/\*\*/g, ".*").replace(/\*/g, "[^\\/]*");
- restRegex = new RegExp(restRegex);
-
- _ls('-R', root).filter(function (e) {
- return restRegex.test(e);
- }).forEach(function(file) {
- expanded.push(file);
- });
- }
- // Wildcard present on file names ?
- else if (listEl.search(/\*/) > -1) {
- _ls('', listEl).forEach(function(file) {
- expanded.push(file);
- });
- } else {
- expanded.push(listEl);
- }
- });
- return expanded;
-}
-exports.expand = expand;
-
-// Normalizes _unlinkSync() across platforms to match Unix behavior, i.e.
-// file can be unlinked even if it's read-only, see https://github.com/joyent/node/issues/3006
-function unlinkSync(file) {
- try {
- fs.unlinkSync(file);
- } catch(e) {
- // Try to override file permission
- if (e.code === 'EPERM') {
- fs.chmodSync(file, '0666');
- fs.unlinkSync(file);
- } else {
- throw e;
- }
- }
-}
-exports.unlinkSync = unlinkSync;
-
-// e.g. 'shelljs_a5f185d0443ca...'
-function randomFileName() {
- function randomHash(count) {
- if (count === 1)
- return parseInt(16*Math.random(), 10).toString(16);
- else {
- var hash = '';
- for (var i=0; i<count; i++)
- hash += randomHash(1);
- return hash;
- }
- }
-
- return 'shelljs_'+randomHash(20);
-}
-exports.randomFileName = randomFileName;
-
-// extend(target_obj, source_obj1 [, source_obj2 ...])
-// Shallow extend, e.g.:
-// extend({A:1}, {b:2}, {c:3}) returns {A:1, b:2, c:3}
-function extend(target) {
- var sources = [].slice.call(arguments, 1);
- sources.forEach(function(source) {
- for (var key in source)
- target[key] = source[key];
- });
-
- return target;
-}
-exports.extend = extend;
-
-// Common wrapper for all Unix-like commands
-function wrap(cmd, fn, options) {
- return function() {
- var retValue = null;
-
- state.currentCmd = cmd;
- state.error = null;
-
- try {
- var args = [].slice.call(arguments, 0);
-
- if (config.verbose) {
- args.unshift(cmd);
- console.log.apply(console, args);
- args.shift();
- }
-
- if (options && options.notUnix) {
- retValue = fn.apply(this, args);
- } else {
- if (args.length === 0 || typeof args[0] !== 'string' || args[0].length <= 1 || args[0][0] !== '-')
- args.unshift(''); // only add dummy option if '-option' not already present
- // Expand the '~' if appropriate
- var homeDir = getUserHome();
- args = args.map(function(arg) {
- if (typeof arg === 'string' && arg.slice(0, 2) === '~/' || arg === '~')
- return arg.replace(/^~/, homeDir);
- else
- return arg;
- });
- retValue = fn.apply(this, args);
- }
- } catch (e) {
- if (!state.error) {
- // If state.error hasn't been set it's an error thrown by Node, not us - probably a bug...
- console.log('shell.js: internal error');
- console.log(e.stack || e);
- process.exit(1);
- }
- if (config.fatal)
- throw e;
- }
-
- state.currentCmd = 'shell.js';
- return retValue;
- };
-} // wrap
-exports.wrap = wrap;
-
-var fs = require('fs');
-var path = require('path');
-var common = require('./common');
-var os = require('os');
-
-// Buffered file copy, synchronous
-// (Using readFileSync() + writeFileSync() could easily cause a memory overflow
-// with large files)
-function copyFileSync(srcFile, destFile) {
- if (!fs.existsSync(srcFile))
- common.error('copyFileSync: no such file or directory: ' + srcFile);
-
- var BUF_LENGTH = 64*1024,
- buf = new Buffer(BUF_LENGTH),
- bytesRead = BUF_LENGTH,
- pos = 0,
- fdr = null,
- fdw = null;
-
- try {
- fdr = fs.openSync(srcFile, 'r');
- } catch(e) {
- common.error('copyFileSync: could not read src file ('+srcFile+')');
- }
-
- try {
- fdw = fs.openSync(destFile, 'w');
- } catch(e) {
- common.error('copyFileSync: could not write to dest file (code='+e.code+'):'+destFile);
- }
-
- while (bytesRead === BUF_LENGTH) {
- bytesRead = fs.readSync(fdr, buf, 0, BUF_LENGTH, pos);
- fs.writeSync(fdw, buf, 0, bytesRead);
- pos += bytesRead;
- }
-
- fs.closeSync(fdr);
- fs.closeSync(fdw);
-
- fs.chmodSync(destFile, fs.statSync(srcFile).mode);
-}
-
-// Recursively copies 'sourceDir' into 'destDir'
-// Adapted from https://github.com/ryanmcgrath/wrench-js
-//
-// Copyright (c) 2010 Ryan McGrath
-// Copyright (c) 2012 Artur Adib
-//
-// Licensed under the MIT License
-// http://www.opensource.org/licenses/mit-license.php
-function cpdirSyncRecursive(sourceDir, destDir, opts) {
- if (!opts) opts = {};
-
- /* Create the directory where all our junk is moving to; read the mode of the source directory and mirror it */
- var checkDir = fs.statSync(sourceDir);
- try {
- fs.mkdirSync(destDir, checkDir.mode);
- } catch (e) {
- //if the directory already exists, that's okay
- if (e.code !== 'EEXIST') throw e;
- }
-
- var files = fs.readdirSync(sourceDir);
-
- for (var i = 0; i < files.length; i++) {
- var srcFile = sourceDir + "/" + files[i];
- var destFile = destDir + "/" + files[i];
- var srcFileStat = fs.lstatSync(srcFile);
-
- if (srcFileStat.isDirectory()) {
- /* recursion this thing right on back. */
- cpdirSyncRecursive(srcFile, destFile, opts);
- } else if (srcFileStat.isSymbolicLink()) {
- var symlinkFull = fs.readlinkSync(srcFile);
- fs.symlinkSync(symlinkFull, destFile, os.platform() === "win32" ? "junction" : null);
- } else {
- /* At this point, we've hit a file actually worth copying... so copy it on over. */
- if (fs.existsSync(destFile) && opts.no_force) {
- common.log('skipping existing file: ' + files[i]);
- } else {
- copyFileSync(srcFile, destFile);
- }
- }
-
- } // for files
-} // cpdirSyncRecursive
-
-
-//@
-//@ ### cp([options,] source [, source ...], dest)
-//@ ### cp([options,] source_array, dest)
-//@ Available options:
-//@
-//@ + `-f`: force (default behavior)
-//@ + `-n`: no-clobber
-//@ + `-r, -R`: recursive
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ cp('file1', 'dir1');
-//@ cp('-Rf', '/tmp/*', '/usr/local/*', '/home/tmp');
-//@ cp('-Rf', ['/tmp/*', '/usr/local/*'], '/home/tmp'); // same as above
-//@ ```
-//@
-//@ Copies files. The wildcard `*` is accepted.
-function _cp(options, sources, dest) {
- options = common.parseOptions(options, {
- 'f': '!no_force',
- 'n': 'no_force',
- 'R': 'recursive',
- 'r': 'recursive'
- });
-
- // Get sources, dest
- if (arguments.length < 3) {
- common.error('missing <source> and/or <dest>');
- } else if (arguments.length > 3) {
- sources = [].slice.call(arguments, 1, arguments.length - 1);
- dest = arguments[arguments.length - 1];
- } else if (typeof sources === 'string') {
- sources = [sources];
- } else if ('length' in sources) {
- sources = sources; // no-op for array
- } else {
- common.error('invalid arguments');
- }
-
- var exists = fs.existsSync(dest),
- stats = exists && fs.statSync(dest);
-
- // Dest is not existing dir, but multiple sources given
- if ((!exists || !stats.isDirectory()) && sources.length > 1)
- common.error('dest is not a directory (too many sources)');
-
- // Dest is an existing file, but no -f given
- if (exists && stats.isFile() && options.no_force)
- common.error('dest file already exists: ' + dest);
-
- if (options.recursive) {
- // Recursive allows the shortcut syntax "sourcedir/" for "sourcedir/*"
- // (see Github issue #15)
- sources.forEach(function(src, i) {
- if (src[src.length - 1] === '/') {
- sources[i] += '*';
- // If src is a directory and dest doesn't exist, 'cp -r src dest' should copy src/* into dest
- } else if (fs.statSync(src).isDirectory() && !exists) {
- sources[i] += '/*';
- }
- });
-
- // Create dest
- try {
- fs.mkdirSync(dest, parseInt('0777', 8));
- } catch (e) {
- // like Unix's cp, keep going even if we can't create dest dir
- }
- }
-
- sources = common.expand(sources);
-
- sources.forEach(function(src) {
- if (!fs.existsSync(src)) {
- common.error('no such file or directory: '+src, true);
- return; // skip file
- }
-
- // If here, src exists
- if (fs.statSync(src).isDirectory()) {
- if (!options.recursive) {
- // Non-Recursive
- common.log(src + ' is a directory (not copied)');
- } else {
- // Recursive
- // 'cp /a/source dest' should create 'source' in 'dest'
- var newDest = path.join(dest, path.basename(src)),
- checkDir = fs.statSync(src);
- try {
- fs.mkdirSync(newDest, checkDir.mode);
- } catch (e) {
- //if the directory already exists, that's okay
- if (e.code !== 'EEXIST') {
- common.error('dest file no such file or directory: ' + newDest, true);
- throw e;
- }
- }
-
- cpdirSyncRecursive(src, newDest, {no_force: options.no_force});
- }
- return; // done with dir
- }
-
- // If here, src is a file
-
- // When copying to '/path/dir':
- // thisDest = '/path/dir/file1'
- var thisDest = dest;
- if (fs.existsSync(dest) && fs.statSync(dest).isDirectory())
- thisDest = path.normalize(dest + '/' + path.basename(src));
-
- if (fs.existsSync(thisDest) && options.no_force) {
- common.error('dest file already exists: ' + thisDest, true);
- return; // skip file
- }
-
- copyFileSync(src, thisDest);
- }); // forEach(src)
-}
-module.exports = _cp;
-
-var common = require('./common');
-var _cd = require('./cd');
-var path = require('path');
-
-// Pushd/popd/dirs internals
-var _dirStack = [];
-
-function _isStackIndex(index) {
- return (/^[\-+]\d+$/).test(index);
-}
-
-function _parseStackIndex(index) {
- if (_isStackIndex(index)) {
- if (Math.abs(index) < _dirStack.length + 1) { // +1 for pwd
- return (/^-/).test(index) ? Number(index) - 1 : Number(index);
- } else {
- common.error(index + ': directory stack index out of range');
- }
- } else {
- common.error(index + ': invalid number');
- }
-}
-
-function _actualDirStack() {
- return [process.cwd()].concat(_dirStack);
-}
-
-//@
-//@ ### pushd([options,] [dir | '-N' | '+N'])
-//@
-//@ Available options:
-//@
-//@ + `-n`: Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated.
-//@
-//@ Arguments:
-//@
-//@ + `dir`: Makes the current working directory be the top of the stack, and then executes the equivalent of `cd dir`.
-//@ + `+N`: Brings the Nth directory (counting from the left of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.
-//@ + `-N`: Brings the Nth directory (counting from the right of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ // process.cwd() === '/usr'
-//@ pushd('/etc'); // Returns /etc /usr
-//@ pushd('+1'); // Returns /usr /etc
-//@ ```
-//@
-//@ Save the current directory on the top of the directory stack and then cd to `dir`. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack.
-function _pushd(options, dir) {
- if (_isStackIndex(options)) {
- dir = options;
- options = '';
- }
-
- options = common.parseOptions(options, {
- 'n' : 'no-cd'
- });
-
- var dirs = _actualDirStack();
-
- if (dir === '+0') {
- return dirs; // +0 is a noop
- } else if (!dir) {
- if (dirs.length > 1) {
- dirs = dirs.splice(1, 1).concat(dirs);
- } else {
- return common.error('no other directory');
- }
- } else if (_isStackIndex(dir)) {
- var n = _parseStackIndex(dir);
- dirs = dirs.slice(n).concat(dirs.slice(0, n));
- } else {
- if (options['no-cd']) {
- dirs.splice(1, 0, dir);
- } else {
- dirs.unshift(dir);
- }
- }
-
- if (options['no-cd']) {
- dirs = dirs.slice(1);
- } else {
- dir = path.resolve(dirs.shift());
- _cd('', dir);
- }
-
- _dirStack = dirs;
- return _dirs('');
-}
-exports.pushd = _pushd;
-
-//@
-//@ ### popd([options,] ['-N' | '+N'])
-//@
-//@ Available options:
-//@
-//@ + `-n`: Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated.
-//@
-//@ Arguments:
-//@
-//@ + `+N`: Removes the Nth directory (counting from the left of the list printed by dirs), starting with zero.
-//@ + `-N`: Removes the Nth directory (counting from the right of the list printed by dirs), starting with zero.
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ echo(process.cwd()); // '/usr'
-//@ pushd('/etc'); // '/etc /usr'
-//@ echo(process.cwd()); // '/etc'
-//@ popd(); // '/usr'
-//@ echo(process.cwd()); // '/usr'
-//@ ```
-//@
-//@ When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack.
-function _popd(options, index) {
- if (_isStackIndex(options)) {
- index = options;
- options = '';
- }
-
- options = common.parseOptions(options, {
- 'n' : 'no-cd'
- });
-
- if (!_dirStack.length) {
- return common.error('directory stack empty');
- }
-
- index = _parseStackIndex(index || '+0');
-
- if (options['no-cd'] || index > 0 || _dirStack.length + index === 0) {
- index = index > 0 ? index - 1 : index;
- _dirStack.splice(index, 1);
- } else {
- var dir = path.resolve(_dirStack.shift());
- _cd('', dir);
- }
-
- return _dirs('');
-}
-exports.popd = _popd;
-
-//@
-//@ ### dirs([options | '+N' | '-N'])
-//@
-//@ Available options:
-//@
-//@ + `-c`: Clears the directory stack by deleting all of the elements.
-//@
-//@ Arguments:
-//@
-//@ + `+N`: Displays the Nth directory (counting from the left of the list printed by dirs when invoked without options), starting with zero.
-//@ + `-N`: Displays the Nth directory (counting from the right of the list printed by dirs when invoked without options), starting with zero.
-//@
-//@ Display the list of currently remembered directories. Returns an array of paths in the stack, or a single path if +N or -N was specified.
-//@
-//@ See also: pushd, popd
-function _dirs(options, index) {
- if (_isStackIndex(options)) {
- index = options;
- options = '';
- }
-
- options = common.parseOptions(options, {
- 'c' : 'clear'
- });
-
- if (options['clear']) {
- _dirStack = [];
- return _dirStack;
- }
-
- var stack = _actualDirStack();
-
- if (index) {
- index = _parseStackIndex(index);
-
- if (index < 0) {
- index = stack.length + index;
- }
-
- common.log(stack[index]);
- return stack[index];
- }
-
- common.log(stack.join(' '));
-
- return stack;
-}
-exports.dirs = _dirs;
-
-var common = require('./common');
-
-//@
-//@ ### echo(string [, string ...])
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ echo('hello world');
-//@ var str = echo('hello world');
-//@ ```
-//@
-//@ Prints string to stdout, and returns string with additional utility methods
-//@ like `.to()`.
-function _echo() {
- var messages = [].slice.call(arguments, 0);
- console.log.apply(console, messages);
- return common.ShellString(messages.join(' '));
-}
-module.exports = _echo;
-
-var common = require('./common');
-
-//@
-//@ ### error()
-//@ Tests if error occurred in the last command. Returns `null` if no error occurred,
-//@ otherwise returns string explaining the error
-function error() {
- return common.state.error;
-}
-module.exports = error;
-
-var common = require('./common');
-var _tempDir = require('./tempdir');
-var _pwd = require('./pwd');
-var path = require('path');
-var fs = require('fs');
-var child = require('child_process');
-
-// Hack to run child_process.exec() synchronously (sync avoids callback hell)
-// Uses a custom wait loop that checks for a flag file, created when the child process is done.
-// (Can't do a wait loop that checks for internal Node variables/messages as
-// Node is single-threaded; callbacks and other internal state changes are done in the
-// event loop).
-function execSync(cmd, opts) {
- var tempDir = _tempDir();
- var stdoutFile = path.resolve(tempDir+'/'+common.randomFileName()),
- stderrFile = path.resolve(tempDir+'/'+common.randomFileName()),
- codeFile = path.resolve(tempDir+'/'+common.randomFileName()),
- scriptFile = path.resolve(tempDir+'/'+common.randomFileName()),
- sleepFile = path.resolve(tempDir+'/'+common.randomFileName());
-
- var options = common.extend({
- silent: common.config.silent
- }, opts);
-
- var previousStdoutContent = '',
- previousStderrContent = '';
- // Echoes stdout and stderr changes from running process, if not silent
- function updateStream(streamFile) {
- if (options.silent || !fs.existsSync(streamFile))
- return;
-
- var previousStreamContent,
- proc_stream;
- if (streamFile === stdoutFile) {
- previousStreamContent = previousStdoutContent;
- proc_stream = process.stdout;
- } else { // assume stderr
- previousStreamContent = previousStderrContent;
- proc_stream = process.stderr;
- }
-
- var streamContent = fs.readFileSync(streamFile, 'utf8');
- // No changes since last time?
- if (streamContent.length <= previousStreamContent.length)
- return;
-
- proc_stream.write(streamContent.substr(previousStreamContent.length));
- previousStreamContent = streamContent;
- }
-
- function escape(str) {
- return (str+'').replace(/([\\"'])/g, "\\$1").replace(/\0/g, "\\0");
- }
-
- if (fs.existsSync(scriptFile)) common.unlinkSync(scriptFile);
- if (fs.existsSync(stdoutFile)) common.unlinkSync(stdoutFile);
- if (fs.existsSync(stderrFile)) common.unlinkSync(stderrFile);
- if (fs.existsSync(codeFile)) common.unlinkSync(codeFile);
-
- var execCommand = '"'+process.execPath+'" '+scriptFile;
- var execOptions = {
- env: process.env,
- cwd: _pwd(),
- maxBuffer: 20*1024*1024
- };
-
- var script;
-
- if (typeof child.execSync === 'function') {
- script = [
- "var child = require('child_process')",
- " , fs = require('fs');",
- "var childProcess = child.exec('"+escape(cmd)+"', {env: process.env, maxBuffer: 20*1024*1024}, function(err) {",
- " fs.writeFileSync('"+escape(codeFile)+"', err ? err.code.toString() : '0');",
- "});",
- "var stdoutStream = fs.createWriteStream('"+escape(stdoutFile)+"');",
- "var stderrStream = fs.createWriteStream('"+escape(stderrFile)+"');",
- "childProcess.stdout.pipe(stdoutStream, {end: false});",
- "childProcess.stderr.pipe(stderrStream, {end: false});",
- "childProcess.stdout.pipe(process.stdout);",
- "childProcess.stderr.pipe(process.stderr);",
- "var stdoutEnded = false, stderrEnded = false;",
- "function tryClosingStdout(){ if(stdoutEnded){ stdoutStream.end(); } }",
- "function tryClosingStderr(){ if(stderrEnded){ stderrStream.end(); } }",
- "childProcess.stdout.on('end', function(){ stdoutEnded = true; tryClosingStdout(); });",
- "childProcess.stderr.on('end', function(){ stderrEnded = true; tryClosingStderr(); });"
- ].join('\n');
-
- fs.writeFileSync(scriptFile, script);
-
- if (options.silent) {
- execOptions.stdio = 'ignore';
- } else {
- execOptions.stdio = [0, 1, 2];
- }
-
- // Welcome to the future
- child.execSync(execCommand, execOptions);
- } else {
- cmd += ' > '+stdoutFile+' 2> '+stderrFile; // works on both win/unix
-
- script = [
- "var child = require('child_process')",
- " , fs = require('fs');",
- "var childProcess = child.exec('"+escape(cmd)+"', {env: process.env, maxBuffer: 20*1024*1024}, function(err) {",
- " fs.writeFileSync('"+escape(codeFile)+"', err ? err.code.toString() : '0');",
- "});"
- ].join('\n');
-
- fs.writeFileSync(scriptFile, script);
-
- child.exec(execCommand, execOptions);
-
- // The wait loop
- // sleepFile is used as a dummy I/O op to mitigate unnecessary CPU usage
- // (tried many I/O sync ops, writeFileSync() seems to be only one that is effective in reducing
- // CPU usage, though apparently not so much on Windows)
- while (!fs.existsSync(codeFile)) { updateStream(stdoutFile); fs.writeFileSync(sleepFile, 'a'); }
- while (!fs.existsSync(stdoutFile)) { updateStream(stdoutFile); fs.writeFileSync(sleepFile, 'a'); }
- while (!fs.existsSync(stderrFile)) { updateStream(stderrFile); fs.writeFileSync(sleepFile, 'a'); }
- }
-
- // At this point codeFile exists, but it's not necessarily flushed yet.
- // Keep reading it until it is.
- var code = parseInt('', 10);
- while (isNaN(code)) {
- code = parseInt(fs.readFileSync(codeFile, 'utf8'), 10);
- }
-
- var stdout = fs.readFileSync(stdoutFile, 'utf8');
- var stderr = fs.readFileSync(stderrFile, 'utf8');
-
- // No biggie if we can't erase the files now -- they're in a temp dir anyway
- try { common.unlinkSync(scriptFile); } catch(e) {}
- try { common.unlinkSync(stdoutFile); } catch(e) {}
- try { common.unlinkSync(stderrFile); } catch(e) {}
- try { common.unlinkSync(codeFile); } catch(e) {}
- try { common.unlinkSync(sleepFile); } catch(e) {}
-
- // some shell return codes are defined as errors, per http://tldp.org/LDP/abs/html/exitcodes.html
- if (code === 1 || code === 2 || code >= 126) {
- common.error('', true); // unix/shell doesn't really give an error message after non-zero exit codes
- }
- // True if successful, false if not
- var obj = {
- code: code,
- output: stdout, // deprecated
- stdout: stdout,
- stderr: stderr
- };
- return obj;
-} // execSync()
-
-// Wrapper around exec() to enable echoing output to console in real time
-function execAsync(cmd, opts, callback) {
- var stdout = '';
- var stderr = '';
-
- var options = common.extend({
- silent: common.config.silent
- }, opts);
-
- var c = child.exec(cmd, {env: process.env, maxBuffer: 20*1024*1024}, function(err) {
- if (callback)
- callback(err ? err.code : 0, stdout, stderr);
- });
-
- c.stdout.on('data', function(data) {
- stdout += data;
- if (!options.silent)
- process.stdout.write(data);
- });
-
- c.stderr.on('data', function(data) {
- stderr += data;
- if (!options.silent)
- process.stderr.write(data);
- });
-
- return c;
-}
-
-//@
-//@ ### exec(command [, options] [, callback])
-//@ Available options (all `false` by default):
-//@
-//@ + `async`: Asynchronous execution. If a callback is provided, it will be set to
-//@ `true`, regardless of the passed value.
-//@ + `silent`: Do not echo program output to console.
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ var version = exec('node --version', {silent:true}).stdout;
-//@
-//@ var child = exec('some_long_running_process', {async:true});
-//@ child.stdout.on('data', function(data) {
-//@ /* ... do something with data ... */
-//@ });
-//@
-//@ exec('some_long_running_process', function(code, stdout, stderr) {
-//@ console.log('Exit code:', code);
-//@ console.log('Program output:', stdout);
-//@ console.log('Program stderr:', stderr);
-//@ });
-//@ ```
-//@
-//@ Executes the given `command` _synchronously_, unless otherwise specified. When in synchronous
-//@ mode returns the object `{ code:..., stdout:... , stderr:... }`, containing the program's
-//@ `stdout`, `stderr`, and its exit `code`. Otherwise returns the child process object,
-//@ and the `callback` gets the arguments `(code, stdout, stderr)`.
-//@
-//@ **Note:** For long-lived processes, it's best to run `exec()` asynchronously as
-//@ the current synchronous implementation uses a lot of CPU. This should be getting
-//@ fixed soon.
-function _exec(command, options, callback) {
- if (!command)
- common.error('must specify command');
-
- // Callback is defined instead of options.
- if (typeof options === 'function') {
- callback = options;
- options = { async: true };
- }
-
- // Callback is defined with options.
- if (typeof options === 'object' && typeof callback === 'function') {
- options.async = true;
- }
-
- options = common.extend({
- silent: common.config.silent,
- async: false
- }, options);
-
- if (options.async)
- return execAsync(command, options, callback);
- else
- return execSync(command, options);
-}
-module.exports = _exec;
-
-var fs = require('fs');
-var common = require('./common');
-var _ls = require('./ls');
-
-//@
-//@ ### find(path [, path ...])
-//@ ### find(path_array)
-//@ Examples:
-//@
-//@ ```javascript
-//@ find('src', 'lib');
-//@ find(['src', 'lib']); // same as above
-//@ find('.').filter(function(file) { return file.match(/\.js$/); });
-//@ ```
-//@
-//@ Returns array of all files (however deep) in the given paths.
-//@
-//@ The main difference from `ls('-R', path)` is that the resulting file names
-//@ include the base directories, e.g. `lib/resources/file1` instead of just `file1`.
-function _find(options, paths) {
- if (!paths)
- common.error('no path specified');
- else if (typeof paths === 'object')
- paths = paths; // assume array
- else if (typeof paths === 'string')
- paths = [].slice.call(arguments, 1);
-
- var list = [];
-
- function pushFile(file) {
- if (common.platform === 'win')
- file = file.replace(/\\/g, '/');
- list.push(file);
- }
-
- // why not simply do ls('-R', paths)? because the output wouldn't give the base dirs
- // to get the base dir in the output, we need instead ls('-R', 'dir/*') for every directory
-
- paths.forEach(function(file) {
- pushFile(file);
-
- if (fs.statSync(file).isDirectory()) {
- _ls('-RA', file+'/*').forEach(function(subfile) {
- pushFile(subfile);
- });
- }
- });
-
- return list;
-}
-module.exports = _find;
-
-var common = require('./common');
-var fs = require('fs');
-
-//@
-//@ ### grep([options,] regex_filter, file [, file ...])
-//@ ### grep([options,] regex_filter, file_array)
-//@ Available options:
-//@
-//@ + `-v`: Inverse the sense of the regex and print the lines not matching the criteria.
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ grep('-v', 'GLOBAL_VARIABLE', '*.js');
-//@ grep('GLOBAL_VARIABLE', '*.js');
-//@ ```
-//@
-//@ Reads input string from given files and returns a string containing all lines of the
-//@ file that match the given `regex_filter`. Wildcard `*` accepted.
-function _grep(options, regex, files) {
- options = common.parseOptions(options, {
- 'v': 'inverse'
- });
-
- if (!files)
- common.error('no paths given');
-
- if (typeof files === 'string')
- files = [].slice.call(arguments, 2);
- // if it's array leave it as it is
-
- files = common.expand(files);
-
- var grep = '';
- files.forEach(function(file) {
- if (!fs.existsSync(file)) {
- common.error('no such file or directory: ' + file, true);
- return;
- }
-
- var contents = fs.readFileSync(file, 'utf8'),
- lines = contents.split(/\r*\n/);
- lines.forEach(function(line) {
- var matched = line.match(regex);
- if ((options.inverse && !matched) || (!options.inverse && matched))
- grep += line + '\n';
- });
- });
-
- return common.ShellString(grep);
-}
-module.exports = _grep;
-
-var fs = require('fs');
-var path = require('path');
-var common = require('./common');
-
-//@
-//@ ### ln([options,] source, dest)
-//@ Available options:
-//@
-//@ + `-s`: symlink
-//@ + `-f`: force
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ ln('file', 'newlink');
-//@ ln('-sf', 'file', 'existing');
-//@ ```
-//@
-//@ Links source to dest. Use -f to force the link, should dest already exist.
-function _ln(options, source, dest) {
- options = common.parseOptions(options, {
- 's': 'symlink',
- 'f': 'force'
- });
-
- if (!source || !dest) {
- common.error('Missing <source> and/or <dest>');
- }
-
- source = String(source);
- var sourcePath = path.normalize(source).replace(RegExp(path.sep + '$'), '');
- var isAbsolute = (path.resolve(source) === sourcePath);
- dest = path.resolve(process.cwd(), String(dest));
-
- if (fs.existsSync(dest)) {
- if (!options.force) {
- common.error('Destination file exists', true);
- }
-
- fs.unlinkSync(dest);
- }
-
- if (options.symlink) {
- var isWindows = common.platform === 'win';
- var linkType = isWindows ? 'file' : null;
- var resolvedSourcePath = isAbsolute ? sourcePath : path.resolve(process.cwd(), path.dirname(dest), source);
- if (!fs.existsSync(resolvedSourcePath)) {
- common.error('Source file does not exist', true);
- } else if (isWindows && fs.statSync(resolvedSourcePath).isDirectory()) {
- linkType = 'junction';
- }
-
- try {
- fs.symlinkSync(linkType === 'junction' ? resolvedSourcePath: source, dest, linkType);
- } catch (err) {
- common.error(err.message);
- }
- } else {
- if (!fs.existsSync(source)) {
- common.error('Source file does not exist', true);
- }
- try {
- fs.linkSync(source, dest);
- } catch (err) {
- common.error(err.message);
- }
- }
-}
-module.exports = _ln;
-
-var path = require('path');
-var fs = require('fs');
-var common = require('./common');
-var _cd = require('./cd');
-var _pwd = require('./pwd');
-
-//@
-//@ ### ls([options,] [path, ...])
-//@ ### ls([options,] path_array)
-//@ Available options:
-//@
-//@ + `-R`: recursive
-//@ + `-A`: all files (include files beginning with `.`, except for `.` and `..`)
-//@ + `-d`: list directories themselves, not their contents
-//@ + `-l`: list objects representing each file, each with fields containing `ls
-//@ -l` output fields. See
-//@ [fs.Stats](https://nodejs.org/api/fs.html#fs_class_fs_stats)
-//@ for more info
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ ls('projs/*.js');
-//@ ls('-R', '/users/me', '/tmp');
-//@ ls('-R', ['/users/me', '/tmp']); // same as above
-//@ ls('-l', 'file.txt'); // { name: 'file.txt', mode: 33188, nlink: 1, ...}
-//@ ```
-//@
-//@ Returns array of files in the given path, or in current directory if no path provided.
-function _ls(options, paths) {
- options = common.parseOptions(options, {
- 'R': 'recursive',
- 'A': 'all',
- 'a': 'all_deprecated',
- 'd': 'directory',
- 'l': 'long'
- });
-
- if (options.all_deprecated) {
- // We won't support the -a option as it's hard to image why it's useful
- // (it includes '.' and '..' in addition to '.*' files)
- // For backwards compatibility we'll dump a deprecated message and proceed as before
- common.log('ls: Option -a is deprecated. Use -A instead');
- options.all = true;
- }
-
- if (!paths)
- paths = ['.'];
- else if (typeof paths === 'object')
- paths = paths; // assume array
- else if (typeof paths === 'string')
- paths = [].slice.call(arguments, 1);
-
- var list = [];
-
- // Conditionally pushes file to list - returns true if pushed, false otherwise
- // (e.g. prevents hidden files to be included unless explicitly told so)
- function pushFile(file, query) {
- var name = file.name || file;
- // hidden file?
- if (path.basename(name)[0] === '.') {
- // not explicitly asking for hidden files?
- if (!options.all && !(path.basename(query)[0] === '.' && path.basename(query).length > 1))
- return false;
- }
-
- if (common.platform === 'win')
- name = name.replace(/\\/g, '/');
-
- if (file.name) {
- file.name = name;
- } else {
- file = name;
- }
- list.push(file);
- return true;
- }
-
- paths.forEach(function(p) {
- if (fs.existsSync(p)) {
- var stats = ls_stat(p);
- // Simple file?
- if (stats.isFile()) {
- if (options.long) {
- pushFile(stats, p);
- } else {
- pushFile(p, p);
- }
- return; // continue
- }
-
- // Simple dir?
- if (options.directory) {
- pushFile(p, p);
- return;
- } else if (stats.isDirectory()) {
- // Iterate over p contents
- fs.readdirSync(p).forEach(function(file) {
- var orig_file = file;
- if (options.long)
- file = ls_stat(path.join(p, file));
- if (!pushFile(file, p))
- return;
-
- // Recursive?
- if (options.recursive) {
- var oldDir = _pwd();
- _cd('', p);
- if (fs.statSync(orig_file).isDirectory())
- list = list.concat(_ls('-R'+(options.all?'A':''), orig_file+'/*'));
- _cd('', oldDir);
- }
- });
- return; // continue
- }
- }
-
- // p does not exist - possible wildcard present
-
- var basename = path.basename(p);
- var dirname = path.dirname(p);
- // Wildcard present on an existing dir? (e.g. '/tmp/*.js')
- if (basename.search(/\*/) > -1 && fs.existsSync(dirname) && fs.statSync(dirname).isDirectory) {
- // Escape special regular expression chars
- var regexp = basename.replace(/(\^|\$|\(|\)|<|>|\[|\]|\{|\}|\.|\+|\?)/g, '\\$1');
- // Translates wildcard into regex
- regexp = '^' + regexp.replace(/\*/g, '.*') + '$';
- // Iterate over directory contents
- fs.readdirSync(dirname).forEach(function(file) {
- if (file.match(new RegExp(regexp))) {
- var file_path = path.join(dirname, file);
- file_path = options.long ? ls_stat(file_path) : file_path;
- if (file_path.name)
- file_path.name = path.normalize(file_path.name);
- else
- file_path = path.normalize(file_path);
- if (!pushFile(file_path, basename))
- return;
-
- // Recursive?
- if (options.recursive) {
- var pp = dirname + '/' + file;
- if (fs.lstatSync(pp).isDirectory())
- list = list.concat(_ls('-R'+(options.all?'A':''), pp+'/*'));
- } // recursive
- } // if file matches
- }); // forEach
- return;
- }
-
- common.error('no such file or directory: ' + p, true);
- });
-
- return list;
-}
-module.exports = _ls;
-
-
-function ls_stat(path) {
- var stats = fs.statSync(path);
- // Note: this object will contain more information than .toString() returns
- stats.name = path;
- stats.toString = function() {
- // Return a string resembling unix's `ls -l` format
- return [this.mode, this.nlink, this.uid, this.gid, this.size, this.mtime, this.name].join(' ');
- };
- return stats;
-}
-
-var common = require('./common');
-var fs = require('fs');
-var path = require('path');
-
-// Recursively creates 'dir'
-function mkdirSyncRecursive(dir) {
- var baseDir = path.dirname(dir);
-
- // Base dir exists, no recursion necessary
- if (fs.existsSync(baseDir)) {
- fs.mkdirSync(dir, parseInt('0777', 8));
- return;
- }
-
- // Base dir does not exist, go recursive
- mkdirSyncRecursive(baseDir);
-
- // Base dir created, can create dir
- fs.mkdirSync(dir, parseInt('0777', 8));
-}
-
-//@
-//@ ### mkdir([options,] dir [, dir ...])
-//@ ### mkdir([options,] dir_array)
-//@ Available options:
-//@
-//@ + `-p`: full path (will create intermediate dirs if necessary)
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ mkdir('-p', '/tmp/a/b/c/d', '/tmp/e/f/g');
-//@ mkdir('-p', ['/tmp/a/b/c/d', '/tmp/e/f/g']); // same as above
-//@ ```
-//@
-//@ Creates directories.
-function _mkdir(options, dirs) {
- options = common.parseOptions(options, {
- 'p': 'fullpath'
- });
- if (!dirs)
- common.error('no paths given');
-
- if (typeof dirs === 'string')
- dirs = [].slice.call(arguments, 1);
- // if it's array leave it as it is
-
- dirs.forEach(function(dir) {
- if (fs.existsSync(dir)) {
- if (!options.fullpath)
- common.error('path already exists: ' + dir, true);
- return; // skip dir
- }
-
- // Base dir does not exist, and no -p option given
- var baseDir = path.dirname(dir);
- if (!fs.existsSync(baseDir) && !options.fullpath) {
- common.error('no such file or directory: ' + baseDir, true);
- return; // skip dir
- }
-
- if (options.fullpath)
- mkdirSyncRecursive(dir);
- else
- fs.mkdirSync(dir, parseInt('0777', 8));
- });
-} // mkdir
-module.exports = _mkdir;
-
-var fs = require('fs');
-var path = require('path');
-var common = require('./common');
-
-//@
-//@ ### mv([options ,] source [, source ...], dest')
-//@ ### mv([options ,] source_array, dest')
-//@ Available options:
-//@
-//@ + `-f`: force (default behavior)
-//@ + `-n`: no-clobber
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ mv('-n', 'file', 'dir/');
-//@ mv('file1', 'file2', 'dir/');
-//@ mv(['file1', 'file2'], 'dir/'); // same as above
-//@ ```
-//@
-//@ Moves files. The wildcard `*` is accepted.
-function _mv(options, sources, dest) {
- options = common.parseOptions(options, {
- 'f': '!no_force',
- 'n': 'no_force'
- });
-
- // Get sources, dest
- if (arguments.length < 3) {
- common.error('missing <source> and/or <dest>');
- } else if (arguments.length > 3) {
- sources = [].slice.call(arguments, 1, arguments.length - 1);
- dest = arguments[arguments.length - 1];
- } else if (typeof sources === 'string') {
- sources = [sources];
- } else if ('length' in sources) {
- sources = sources; // no-op for array
- } else {
- common.error('invalid arguments');
- }
-
- sources = common.expand(sources);
-
- var exists = fs.existsSync(dest),
- stats = exists && fs.statSync(dest);
-
- // Dest is not existing dir, but multiple sources given
- if ((!exists || !stats.isDirectory()) && sources.length > 1)
- common.error('dest is not a directory (too many sources)');
-
- // Dest is an existing file, but no -f given
- if (exists && stats.isFile() && options.no_force)
- common.error('dest file already exists: ' + dest);
-
- sources.forEach(function(src) {
- if (!fs.existsSync(src)) {
- common.error('no such file or directory: '+src, true);
- return; // skip file
- }
-
- // If here, src exists
-
- // When copying to '/path/dir':
- // thisDest = '/path/dir/file1'
- var thisDest = dest;
- if (fs.existsSync(dest) && fs.statSync(dest).isDirectory())
- thisDest = path.normalize(dest + '/' + path.basename(src));
-
- if (fs.existsSync(thisDest) && options.no_force) {
- common.error('dest file already exists: ' + thisDest, true);
- return; // skip file
- }
-
- if (path.resolve(src) === path.dirname(path.resolve(thisDest))) {
- common.error('cannot move to self: '+src, true);
- return; // skip file
- }
-
- fs.renameSync(src, thisDest);
- }); // forEach(src)
-} // mv
-module.exports = _mv;
-
-// see dirs.js
-// see dirs.js
-var path = require('path');
-var common = require('./common');
-
-//@
-//@ ### pwd()
-//@ Returns the current directory.
-function _pwd() {
- var pwd = path.resolve(process.cwd());
- return common.ShellString(pwd);
-}
-module.exports = _pwd;
-
-var common = require('./common');
-var fs = require('fs');
-
-// Recursively removes 'dir'
-// Adapted from https://github.com/ryanmcgrath/wrench-js
-//
-// Copyright (c) 2010 Ryan McGrath
-// Copyright (c) 2012 Artur Adib
-//
-// Licensed under the MIT License
-// http://www.opensource.org/licenses/mit-license.php
-function rmdirSyncRecursive(dir, force) {
- var files;
-
- files = fs.readdirSync(dir);
-
- // Loop through and delete everything in the sub-tree after checking it
- for(var i = 0; i < files.length; i++) {
- var file = dir + "/" + files[i],
- currFile = fs.lstatSync(file);
-
- if(currFile.isDirectory()) { // Recursive function back to the beginning
- rmdirSyncRecursive(file, force);
- }
-
- else if(currFile.isSymbolicLink()) { // Unlink symlinks
- if (force || isWriteable(file)) {
- try {
- common.unlinkSync(file);
- } catch (e) {
- common.error('could not remove file (code '+e.code+'): ' + file, true);
- }
- }
- }
-
- else // Assume it's a file - perhaps a try/catch belongs here?
- if (force || isWriteable(file)) {
- try {
- common.unlinkSync(file);
- } catch (e) {
- common.error('could not remove file (code '+e.code+'): ' + file, true);
- }
- }
- }
-
- // Now that we know everything in the sub-tree has been deleted, we can delete the main directory.
- // Huzzah for the shopkeep.
-
- var result;
- try {
- // Retry on windows, sometimes it takes a little time before all the files in the directory are gone
- var start = Date.now();
- while (true) {
- try {
- result = fs.rmdirSync(dir);
- if (fs.existsSync(dir)) throw { code: "EAGAIN" };
- break;
- } catch(er) {
- // In addition to error codes, also check if the directory still exists and loop again if true
- if (process.platform === "win32" && (er.code === "ENOTEMPTY" || er.code === "EBUSY" || er.code === "EPERM" || er.code === "EAGAIN")) {
- if (Date.now() - start > 1000) throw er;
- } else if (er.code === "ENOENT") {
- // Directory did not exist, deletion was successful
- break;
- } else {
- throw er;
- }
- }
- }
- } catch(e) {
- common.error('could not remove directory (code '+e.code+'): ' + dir, true);
- }
-
- return result;
-} // rmdirSyncRecursive
-
-// Hack to determine if file has write permissions for current user
-// Avoids having to check user, group, etc, but it's probably slow
-function isWriteable(file) {
- var writePermission = true;
- try {
- var __fd = fs.openSync(file, 'a');
- fs.closeSync(__fd);
- } catch(e) {
- writePermission = false;
- }
-
- return writePermission;
-}
-
-//@
-//@ ### rm([options,] file [, file ...])
-//@ ### rm([options,] file_array)
-//@ Available options:
-//@
-//@ + `-f`: force
-//@ + `-r, -R`: recursive
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ rm('-rf', '/tmp/*');
-//@ rm('some_file.txt', 'another_file.txt');
-//@ rm(['some_file.txt', 'another_file.txt']); // same as above
-//@ ```
-//@
-//@ Removes files. The wildcard `*` is accepted.
-function _rm(options, files) {
- options = common.parseOptions(options, {
- 'f': 'force',
- 'r': 'recursive',
- 'R': 'recursive'
- });
- if (!files)
- common.error('no paths given');
-
- if (typeof files === 'string')
- files = [].slice.call(arguments, 1);
- // if it's array leave it as it is
-
- files = common.expand(files);
-
- files.forEach(function(file) {
- if (!fs.existsSync(file)) {
- // Path does not exist, no force flag given
- if (!options.force)
- common.error('no such file or directory: '+file, true);
-
- return; // skip file
- }
-
- // If here, path exists
-
- var stats = fs.lstatSync(file);
- if (stats.isFile() || stats.isSymbolicLink()) {
-
- // Do not check for file writing permissions
- if (options.force) {
- common.unlinkSync(file);
- return;
- }
-
- if (isWriteable(file))
- common.unlinkSync(file);
- else
- common.error('permission denied: '+file, true);
-
- return;
- } // simple file
-
- // Path is an existing directory, but no -r flag given
- if (stats.isDirectory() && !options.recursive) {
- common.error('path is a directory', true);
- return; // skip path
- }
-
- // Recursively remove existing directory
- if (stats.isDirectory() && options.recursive) {
- rmdirSyncRecursive(file, options.force);
- }
- }); // forEach(file)
-} // rm
-module.exports = _rm;
-
-var common = require('./common');
-var fs = require('fs');
-
-//@
-//@ ### sed([options,] search_regex, replacement, file [, file ...])
-//@ ### sed([options,] search_regex, replacement, file_array)
-//@ Available options:
-//@
-//@ + `-i`: Replace contents of 'file' in-place. _Note that no backups will be created!_
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ sed('-i', 'PROGRAM_VERSION', 'v0.1.3', 'source.js');
-//@ sed(/.*DELETE_THIS_LINE.*\n/, '', 'source.js');
-//@ ```
-//@
-//@ Reads an input string from `files` and performs a JavaScript `replace()` on the input
-//@ using the given search regex and replacement string or function. Returns the new string after replacement.
-function _sed(options, regex, replacement, files) {
- options = common.parseOptions(options, {
- 'i': 'inplace'
- });
-
- if (typeof replacement === 'string' || typeof replacement === 'function')
- replacement = replacement; // no-op
- else if (typeof replacement === 'number')
- replacement = replacement.toString(); // fallback
- else
- common.error('invalid replacement string');
-
- // Convert all search strings to RegExp
- if (typeof regex === 'string')
- regex = RegExp(regex);
-
- if (!files)
- common.error('no files given');
-
- if (typeof files === 'string')
- files = [].slice.call(arguments, 3);
- // if it's array leave it as it is
-
- files = common.expand(files);
-
- var sed = [];
- files.forEach(function(file) {
- if (!fs.existsSync(file)) {
- common.error('no such file or directory: ' + file, true);
- return;
- }
-
- var result = fs.readFileSync(file, 'utf8').split('\n').map(function (line) {
- return line.replace(regex, replacement);
- }).join('\n');
-
- sed.push(result);
-
- if (options.inplace)
- fs.writeFileSync(file, result, 'utf8');
- });
-
- return common.ShellString(sed.join('\n'));
-}
-module.exports = _sed;
-
-var common = require('./common');
-
-//@
-//@ ### set(options)
-//@ Available options:
-//@
-//@ + `+/-e`: exit upon error (`config.fatal`)
-//@ + `+/-v`: verbose: show all commands (`config.verbose`)
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ set('-e'); // exit upon first error
-//@ set('+e'); // this undoes a "set('-e')"
-//@ ```
-//@
-//@ Sets global configuration variables
-function _set(options) {
- if (!options) {
- var args = [].slice.call(arguments, 0);
- if (args.length < 2)
- common.error('must provide an argument');
- options = args[1];
- }
- var negate = (options[0] === '+');
- if (negate) {
- options = '-' + options.slice(1); // parseOptions needs a '-' prefix
- }
- options = common.parseOptions(options, {
- 'e': 'fatal',
- 'v': 'verbose'
- });
-
- var key;
- if (negate) {
- for (key in options)
- options[key] = !options[key];
- }
-
- for (key in options) {
- // Only change the global config if `negate` is false and the option is true
- // or if `negate` is true and the option is false (aka negate !== option)
- if (negate !== options[key]) {
- common.config[key] = options[key];
- }
- }
- return;
-}
-module.exports = _set;
-
-var common = require('./common');
-var os = require('os');
-var fs = require('fs');
-
-// Returns false if 'dir' is not a writeable directory, 'dir' otherwise
-function writeableDir(dir) {
- if (!dir || !fs.existsSync(dir))
- return false;
-
- if (!fs.statSync(dir).isDirectory())
- return false;
-
- var testFile = dir+'/'+common.randomFileName();
- try {
- fs.writeFileSync(testFile, ' ');
- common.unlinkSync(testFile);
- return dir;
- } catch (e) {
- return false;
- }
-}
-
-
-//@
-//@ ### tempdir()
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ var tmp = tempdir(); // "/tmp" for most *nix platforms
-//@ ```
-//@
-//@ Searches and returns string containing a writeable, platform-dependent temporary directory.
-//@ Follows Python's [tempfile algorithm](http://docs.python.org/library/tempfile.html#tempfile.tempdir).
-function _tempDir() {
- var state = common.state;
- if (state.tempDir)
- return state.tempDir; // from cache
-
- state.tempDir = writeableDir(os.tmpdir && os.tmpdir()) || // node 0.10+
- writeableDir(os.tmpDir && os.tmpDir()) || // node 0.8+
- writeableDir(process.env['TMPDIR']) ||
- writeableDir(process.env['TEMP']) ||
- writeableDir(process.env['TMP']) ||
- writeableDir(process.env['Wimp$ScrapDir']) || // RiscOS
- writeableDir('C:\\TEMP') || // Windows
- writeableDir('C:\\TMP') || // Windows
- writeableDir('\\TEMP') || // Windows
- writeableDir('\\TMP') || // Windows
- writeableDir('/tmp') ||
- writeableDir('/var/tmp') ||
- writeableDir('/usr/tmp') ||
- writeableDir('.'); // last resort
-
- return state.tempDir;
-}
-module.exports = _tempDir;
-
-var common = require('./common');
-var fs = require('fs');
-
-//@
-//@ ### test(expression)
-//@ Available expression primaries:
-//@
-//@ + `'-b', 'path'`: true if path is a block device
-//@ + `'-c', 'path'`: true if path is a character device
-//@ + `'-d', 'path'`: true if path is a directory
-//@ + `'-e', 'path'`: true if path exists
-//@ + `'-f', 'path'`: true if path is a regular file
-//@ + `'-L', 'path'`: true if path is a symbolic link
-//@ + `'-p', 'path'`: true if path is a pipe (FIFO)
-//@ + `'-S', 'path'`: true if path is a socket
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ if (test('-d', path)) { /* do something with dir */ };
-//@ if (!test('-f', path)) continue; // skip if it's a regular file
-//@ ```
-//@
-//@ Evaluates expression using the available primaries and returns corresponding value.
-function _test(options, path) {
- if (!path)
- common.error('no path given');
-
- // hack - only works with unary primaries
- options = common.parseOptions(options, {
- 'b': 'block',
- 'c': 'character',
- 'd': 'directory',
- 'e': 'exists',
- 'f': 'file',
- 'L': 'link',
- 'p': 'pipe',
- 'S': 'socket'
- });
-
- var canInterpret = false;
- for (var key in options)
- if (options[key] === true) {
- canInterpret = true;
- break;
- }
-
- if (!canInterpret)
- common.error('could not interpret expression');
-
- if (options.link) {
- try {
- return fs.lstatSync(path).isSymbolicLink();
- } catch(e) {
- return false;
- }
- }
-
- if (!fs.existsSync(path))
- return false;
-
- if (options.exists)
- return true;
-
- var stats = fs.statSync(path);
-
- if (options.block)
- return stats.isBlockDevice();
-
- if (options.character)
- return stats.isCharacterDevice();
-
- if (options.directory)
- return stats.isDirectory();
-
- if (options.file)
- return stats.isFile();
-
- if (options.pipe)
- return stats.isFIFO();
-
- if (options.socket)
- return stats.isSocket();
-} // test
-module.exports = _test;
-
-var common = require('./common');
-var fs = require('fs');
-var path = require('path');
-
-//@
-//@ ### 'string'.to(file)
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ cat('input.txt').to('output.txt');
-//@ ```
-//@
-//@ Analogous to the redirection operator `>` in Unix, but works with JavaScript strings (such as
-//@ those returned by `cat`, `grep`, etc). _Like Unix redirections, `to()` will overwrite any existing file!_
-function _to(options, file) {
- if (!file)
- common.error('wrong arguments');
-
- if (!fs.existsSync( path.dirname(file) ))
- common.error('no such file or directory: ' + path.dirname(file));
-
- try {
- fs.writeFileSync(file, this.toString(), 'utf8');
- return this;
- } catch(e) {
- common.error('could not write to file (code '+e.code+'): '+file, true);
- }
-}
-module.exports = _to;
-
-var common = require('./common');
-var fs = require('fs');
-var path = require('path');
-
-//@
-//@ ### 'string'.toEnd(file)
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ cat('input.txt').toEnd('output.txt');
-//@ ```
-//@
-//@ Analogous to the redirect-and-append operator `>>` in Unix, but works with JavaScript strings (such as
-//@ those returned by `cat`, `grep`, etc).
-function _toEnd(options, file) {
- if (!file)
- common.error('wrong arguments');
-
- if (!fs.existsSync( path.dirname(file) ))
- common.error('no such file or directory: ' + path.dirname(file));
-
- try {
- fs.appendFileSync(file, this.toString(), 'utf8');
- return this;
- } catch(e) {
- common.error('could not append to file (code '+e.code+'): '+file, true);
- }
-}
-module.exports = _toEnd;
-
-var common = require('./common');
-var fs = require('fs');
-
-//@
-//@ ### touch([options,] file)
-//@ Available options:
-//@
-//@ + `-a`: Change only the access time
-//@ + `-c`: Do not create any files
-//@ + `-m`: Change only the modification time
-//@ + `-d DATE`: Parse DATE and use it instead of current time
-//@ + `-r FILE`: Use FILE's times instead of current time
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ touch('source.js');
-//@ touch('-c', '/path/to/some/dir/source.js');
-//@ touch({ '-r': FILE }, '/path/to/some/dir/source.js');
-//@ ```
-//@
-//@ Update the access and modification times of each FILE to the current time.
-//@ A FILE argument that does not exist is created empty, unless -c is supplied.
-//@ This is a partial implementation of *[touch(1)](http://linux.die.net/man/1/touch)*.
-function _touch(opts, files) {
- opts = common.parseOptions(opts, {
- 'a': 'atime_only',
- 'c': 'no_create',
- 'd': 'date',
- 'm': 'mtime_only',
- 'r': 'reference',
- });
-
- if (!files) {
- common.error('no paths given');
- }
-
-
- if (Array.isArray(files)) {
- files.forEach(function(f) {
- touchFile(opts, f);
- });
- } else if (typeof files === 'string') {
- touchFile(opts, files);
- } else {
- common.error('file arg should be a string file path or an Array of string file paths');
- }
-
-}
-
-function touchFile(opts, file) {
- var stat = tryStatFile(file);
-
- if (stat && stat.isDirectory()) {
- // don't error just exit
- return;
- }
-
- // if the file doesn't already exist and the user has specified --no-create then
- // this script is finished
- if (!stat && opts.no_create) {
- return;
- }
-
- // open the file and then close it. this will create it if it doesn't exist but will
- // not truncate the file
- fs.closeSync(fs.openSync(file, 'a'));
-
- //
- // Set timestamps
- //
-
- // setup some defaults
- var now = new Date();
- var mtime = opts.date || now;
- var atime = opts.date || now;
-
- // use reference file
- if (opts.reference) {
- var refStat = tryStatFile(opts.reference);
- if (!refStat) {
- common.error('failed to get attributess of ' + opts.reference);
- }
- mtime = refStat.mtime;
- atime = refStat.atime;
- } else if (opts.date) {
- mtime = opts.date;
- atime = opts.date;
- }
-
- if (opts.atime_only && opts.mtime_only) {
- // keep the new values of mtime and atime like GNU
- } else if (opts.atime_only) {
- mtime = stat.mtime;
- } else if (opts.mtime_only) {
- atime = stat.atime;
- }
-
- fs.utimesSync(file, atime, mtime);
-}
-
-module.exports = _touch;
-
-function tryStatFile(filePath) {
- try {
- return fs.statSync(filePath);
- } catch (e) {
- return null;
- }
-}
-
-var common = require('./common');
-var fs = require('fs');
-var path = require('path');
-
-// XP's system default value for PATHEXT system variable, just in case it's not
-// set on Windows.
-var XP_DEFAULT_PATHEXT = '.com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh';
-
-// Cross-platform method for splitting environment PATH variables
-function splitPath(p) {
- if (!p)
- return [];
-
- if (common.platform === 'win')
- return p.split(';');
- else
- return p.split(':');
-}
-
-function checkPath(path) {
- return fs.existsSync(path) && !fs.statSync(path).isDirectory();
-}
-
-//@
-//@ ### which(command)
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ var nodeExec = which('node');
-//@ ```
-//@
-//@ Searches for `command` in the system's PATH. On Windows, this uses the
-//@ `PATHEXT` variable to append the extension if it's not already executable.
-//@ Returns string containing the absolute path to the command.
-function _which(options, cmd) {
- if (!cmd)
- common.error('must specify command');
-
- var pathEnv = process.env.path || process.env.Path || process.env.PATH,
- pathArray = splitPath(pathEnv),
- where = null;
-
- // No relative/absolute paths provided?
- if (cmd.search(/\//) === -1) {
- // Search for command in PATH
- pathArray.forEach(function(dir) {
- if (where)
- return; // already found it
-
- var attempt = path.resolve(dir, cmd);
-
- if (common.platform === 'win') {
- attempt = attempt.toUpperCase();
-
- // In case the PATHEXT variable is somehow not set (e.g.
- // child_process.spawn with an empty environment), use the XP default.
- var pathExtEnv = process.env.PATHEXT || XP_DEFAULT_PATHEXT;
- var pathExtArray = splitPath(pathExtEnv.toUpperCase());
- var i;
-
- // If the extension is already in PATHEXT, just return that.
- for (i = 0; i < pathExtArray.length; i++) {
- var ext = pathExtArray[i];
- if (attempt.slice(-ext.length) === ext && checkPath(attempt)) {
- where = attempt;
- return;
- }
- }
-
- // Cycle through the PATHEXT variable
- var baseAttempt = attempt;
- for (i = 0; i < pathExtArray.length; i++) {
- attempt = baseAttempt + pathExtArray[i];
- if (checkPath(attempt)) {
- where = attempt;
- return;
- }
- }
- } else {
- // Assume it's Unix-like
- if (checkPath(attempt)) {
- where = attempt;
- return;
- }
- }
- });
- }
-
- // Command not found anywhere?
- if (!checkPath(cmd) && !where)
- return null;
-
- where = where || path.resolve(cmd);
-
- return common.ShellString(where);
-}
-module.exports = _which;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/global.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/global.js b/node_modules/shelljs/global.js
index 97f0033..b232e66 100644
--- a/node_modules/shelljs/global.js
+++ b/node_modules/shelljs/global.js
@@ -1,3 +1,12 @@
+/* eslint no-extend-native: 0 */
var shell = require('./shell.js');
-for (var cmd in shell)
+var common = require('./src/common');
+Object.keys(shell).forEach(function (cmd) {
global[cmd] = shell[cmd];
+});
+
+var _to = require('./src/to');
+String.prototype.to = common.wrap('to', _to);
+
+var _toEnd = require('./src/toEnd');
+String.prototype.toEnd = common.wrap('toEnd', _toEnd);
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/package.json
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/package.json b/node_modules/shelljs/package.json
index 44cb880..7569f63 100644
--- a/node_modules/shelljs/package.json
+++ b/node_modules/shelljs/package.json
@@ -1,88 +1,144 @@
{
- "name": "shelljs",
- "version": "0.6.0",
- "author": {
- "name": "Artur Adib",
- "email": "arturadib@gmail.com"
+ "_args": [
+ [
+ "shelljs@*",
+ "/Repos/cordova/cordova-browser"
+ ]
+ ],
+ "_from": "shelljs@*",
+ "_id": "shelljs@0.7.7",
+ "_inCache": true,
+ "_installable": true,
+ "_location": "/shelljs",
+ "_nodeVersion": "6.7.0",
+ "_npmOperationalInternal": {
+ "host": "packages-18-east.internal.npmjs.com",
+ "tmp": "tmp/shelljs-0.7.7.tgz_1489041432003_0.056656441651284695"
},
- "description": "Portable Unix shell commands for Node.js",
- "keywords": [
- "unix",
- "shell",
- "makefile",
- "make",
- "jake",
- "synchronous"
+ "_npmUser": {
+ "email": "ntfschr@gmail.com",
+ "name": "nfischer"
+ },
+ "_npmVersion": "3.10.8",
+ "_phantomChildren": {},
+ "_requested": {
+ "name": "shelljs",
+ "raw": "shelljs@*",
+ "rawSpec": "*",
+ "scope": null,
+ "spec": "*",
+ "type": "range"
+ },
+ "_requiredBy": [
+ "/"
],
+ "_resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.7.tgz",
+ "_shasum": "b2f5c77ef97148f4b4f6e22682e10bba8667cff1",
+ "_shrinkwrap": null,
+ "_spec": "shelljs@*",
+ "_where": "/Repos/cordova/cordova-browser",
+ "bin": {
+ "shjs": "./bin/shjs"
+ },
+ "bugs": {
+ "url": "https://github.com/shelljs/shelljs/issues"
+ },
"contributors": [
{
- "name": "Ari Porad",
- "email": "ari@ariporad.com",
- "url": "http://ariporad.com/"
+ "name": "Nate Fischer",
+ "email": "ntfschr@gmail.com",
+ "url": "https://github.com/nfischer"
},
{
- "name": "Nate Fischer",
- "email": "ntfschr@gmail.com"
+ "name": "Brandon Freitag",
+ "email": "freitagbr@gmail.com",
+ "url": "https://github.com/freitagbr"
}
],
- "repository": {
- "type": "git",
- "url": "git://github.com/shelljs/shelljs.git"
+ "dependencies": {
+ "glob": "^7.0.0",
+ "interpret": "^1.0.0",
+ "rechoir": "^0.6.2"
},
- "license": "BSD-3-Clause",
- "homepage": "http://github.com/shelljs/shelljs",
- "main": "./shell.js",
- "scripts": {
- "test": "node scripts/run-tests"
- },
- "bin": {
- "shjs": "./bin/shjs"
- },
- "dependencies": {},
+ "description": "Portable Unix shell commands for Node.js",
"devDependencies": {
+ "ava": "^0.16.0",
+ "codecov": "^1.0.1",
"coffee-script": "^1.10.0",
- "jshint": "~2.1.11"
- },
- "optionalDependencies": {},
- "engines": {
- "node": ">=0.10.0"
- },
- "gitHead": "fe06baf1173ec6f0a70cd58ddb7d373f4c6446f5",
- "bugs": {
- "url": "https://github.com/shelljs/shelljs/issues"
- },
- "_id": "shelljs@0.6.0",
- "_shasum": "ce1ed837b4b0e55b5ec3dab84251ab9dbdc0c7ec",
- "_from": "shelljs@>=0.6.0 <0.7.0",
- "_npmVersion": "3.6.0",
- "_nodeVersion": "5.4.0",
- "_npmUser": {
- "name": "ariporad",
- "email": "ari@ariporad.com"
+ "eslint": "^2.0.0",
+ "eslint-config-airbnb-base": "^3.0.0",
+ "eslint-plugin-import": "^1.11.1",
+ "nyc": "^10.0.0",
+ "shelljs-changelog": "^0.2.0",
+ "shelljs-release": "^0.2.0",
+ "shx": "^0.2.0",
+ "travis-check-changes": "^0.2.0"
},
+ "directories": {},
"dist": {
- "shasum": "ce1ed837b4b0e55b5ec3dab84251ab9dbdc0c7ec",
- "tarball": "http://registry.npmjs.org/shelljs/-/shelljs-0.6.0.tgz"
+ "shasum": "b2f5c77ef97148f4b4f6e22682e10bba8667cff1",
+ "tarball": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.7.tgz"
},
+ "engines": {
+ "iojs": "*",
+ "node": ">=0.11.0"
+ },
+ "files": [
+ "bin",
+ "commands.js",
+ "global.js",
+ "make.js",
+ "plugin.js",
+ "shell.js",
+ "src"
+ ],
+ "gitHead": "95638cc773390920a446e383c40ed8104c7d211d",
+ "homepage": "http://github.com/shelljs/shelljs",
+ "keywords": [
+ "bash",
+ "jake",
+ "make",
+ "makefile",
+ "shell",
+ "shelljs",
+ "synchronous",
+ "unix"
+ ],
+ "license": "BSD-3-Clause",
+ "main": "./shell.js",
"maintainers": [
{
- "name": "ariporad",
- "email": "ari@ariporad.com"
- },
- {
"name": "artur",
"email": "arturadib@gmail.com"
},
{
+ "name": "freitagbr",
+ "email": "freitagbr@gmail.com"
+ },
+ {
"name": "nfischer",
"email": "ntfschr@gmail.com"
}
],
- "_npmOperationalInternal": {
- "host": "packages-6-west.internal.npmjs.com",
- "tmp": "tmp/shelljs-0.6.0.tgz_1454632811074_0.5800695188809186"
+ "name": "shelljs",
+ "optionalDependencies": {},
+ "readme": "ERROR: No README data found!",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/shelljs/shelljs.git"
},
- "directories": {},
- "_resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.6.0.tgz",
- "readme": "ERROR: No README data found!"
+ "scripts": {
+ "after-travis": "travis-check-changes",
+ "changelog": "shelljs-changelog",
+ "codecov": "codecov",
+ "gendocs": "node scripts/generate-docs",
+ "lint": "eslint .",
+ "posttest": "npm run lint",
+ "release:major": "shelljs-release major",
+ "release:minor": "shelljs-release minor",
+ "release:patch": "shelljs-release patch",
+ "test": "nyc --reporter=text --reporter=lcov ava --serial test/*.js",
+ "test-no-coverage": "ava --serial test/*.js"
+ },
+ "version": "0.7.7"
}
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/scripts/generate-docs.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/scripts/generate-docs.js b/node_modules/shelljs/scripts/generate-docs.js
deleted file mode 100644
index 3a31a91..0000000
--- a/node_modules/shelljs/scripts/generate-docs.js
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env node
-/* globals cat, cd, echo, grep, sed */
-require('../global');
-
-echo('Appending docs to README.md');
-
-cd(__dirname + '/..');
-
-// Extract docs from shell.js
-var docs = grep('//@', 'shell.js');
-
-docs = docs.replace(/\/\/\@include (.+)/g, function(match, path) {
- var file = path.match('.js$') ? path : path+'.js';
- return grep('//@', file);
-});
-
-// Remove '//@'
-docs = docs.replace(/\/\/\@ ?/g, '');
-
-// Wipe out the old docs
-cat('README.md').replace(/## Command reference(.|\n)*/, '## Command reference').to('README.md');
-
-// Append new docs to README
-sed('-i', /## Command reference/, '## Command reference\n\n' + docs, 'README.md');
-
-echo('All done.');
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/scripts/run-tests.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/scripts/run-tests.js b/node_modules/shelljs/scripts/run-tests.js
deleted file mode 100755
index e8e7ff2..0000000
--- a/node_modules/shelljs/scripts/run-tests.js
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/env node
-/* globals cd, echo, exec, exit, ls, pwd, test */
-require('../global');
-var common = require('../src/common');
-
-var failed = false;
-
-//
-// Lint
-//
-var JSHINT_BIN = 'node_modules/jshint/bin/jshint';
-cd(__dirname + '/..');
-
-if (!test('-f', JSHINT_BIN)) {
- echo('JSHint not found. Run `npm install` in the root dir first.');
- exit(1);
-}
-
-var jsfiles = common.expand([pwd() + '/*.js',
- pwd() + '/scripts/*.js',
- pwd() + '/src/*.js',
- pwd() + '/test/*.js'
- ]).join(' ');
-if (exec('node ' + pwd() + '/' + JSHINT_BIN + ' ' + jsfiles).code !== 0) {
- failed = true;
- echo('*** JSHINT FAILED! (return code != 0)');
- echo();
-} else {
- echo('All JSHint tests passed');
- echo();
-}
-
-//
-// Unit tests
-//
-cd(__dirname + '/../test');
-ls('*.js').forEach(function(file) {
- echo('Running test:', file);
- if (exec('node ' + file).code !== 123) { // 123 avoids false positives (e.g. premature exit)
- failed = true;
- echo('*** TEST FAILED! (missing exit code "123")');
- echo();
- }
-});
-
-if (failed) {
- echo();
- echo('*******************************************************');
- echo('WARNING: Some tests did not pass!');
- echo('*******************************************************');
- exit(1);
-} else {
- echo();
- echo('All tests passed.');
-}
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/shell.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/shell.js b/node_modules/shelljs/shell.js
index 93aff70..f155f3d 100644
--- a/node_modules/shelljs/shell.js
+++ b/node_modules/shelljs/shell.js
@@ -3,133 +3,59 @@
// Unix shell commands on top of Node's API
//
// Copyright (c) 2012 Artur Adib
-// http://github.com/arturadib/shelljs
+// http://github.com/shelljs/shelljs
//
var common = require('./src/common');
-
//@
//@ All commands run synchronously, unless otherwise stated.
+//@ All commands accept standard bash globbing characters (`*`, `?`, etc.),
+//@ compatible with the [node glob module](https://github.com/isaacs/node-glob).
+//@
+//@ For less-commonly used commands and features, please check out our [wiki
+//@ page](https://github.com/shelljs/shelljs/wiki).
//@
-//@include ./src/cd
-var _cd = require('./src/cd');
-exports.cd = common.wrap('cd', _cd);
-
-//@include ./src/pwd
-var _pwd = require('./src/pwd');
-exports.pwd = common.wrap('pwd', _pwd);
-
-//@include ./src/ls
-var _ls = require('./src/ls');
-exports.ls = common.wrap('ls', _ls);
-
-//@include ./src/find
-var _find = require('./src/find');
-exports.find = common.wrap('find', _find);
-
-//@include ./src/cp
-var _cp = require('./src/cp');
-exports.cp = common.wrap('cp', _cp);
-
-//@include ./src/rm
-var _rm = require('./src/rm');
-exports.rm = common.wrap('rm', _rm);
-
-//@include ./src/mv
-var _mv = require('./src/mv');
-exports.mv = common.wrap('mv', _mv);
-
-//@include ./src/mkdir
-var _mkdir = require('./src/mkdir');
-exports.mkdir = common.wrap('mkdir', _mkdir);
-
-//@include ./src/test
-var _test = require('./src/test');
-exports.test = common.wrap('test', _test);
-
-//@include ./src/cat
-var _cat = require('./src/cat');
-exports.cat = common.wrap('cat', _cat);
-
-//@include ./src/to
-var _to = require('./src/to');
-String.prototype.to = common.wrap('to', _to);
-
-//@include ./src/toEnd
-var _toEnd = require('./src/toEnd');
-String.prototype.toEnd = common.wrap('toEnd', _toEnd);
-
-//@include ./src/sed
-var _sed = require('./src/sed');
-exports.sed = common.wrap('sed', _sed);
-
-//@include ./src/grep
-var _grep = require('./src/grep');
-exports.grep = common.wrap('grep', _grep);
-
-//@include ./src/which
-var _which = require('./src/which');
-exports.which = common.wrap('which', _which);
-
-//@include ./src/echo
-var _echo = require('./src/echo');
-exports.echo = _echo; // don't common.wrap() as it could parse '-options'
-
-//@include ./src/dirs
-var _dirs = require('./src/dirs').dirs;
-exports.dirs = common.wrap("dirs", _dirs);
-var _pushd = require('./src/dirs').pushd;
-exports.pushd = common.wrap('pushd', _pushd);
-var _popd = require('./src/dirs').popd;
-exports.popd = common.wrap("popd", _popd);
+// Include the docs for all the default commands
+//@commands
-//@include ./src/ln
-var _ln = require('./src/ln');
-exports.ln = common.wrap('ln', _ln);
+// Load all default commands
+require('./commands').forEach(function (command) {
+ require('./src/' + command);
+});
//@
//@ ### exit(code)
//@ Exits the current process with the given exit code.
exports.exit = process.exit;
+//@include ./src/error
+exports.error = require('./src/error');
+
+//@include ./src/common
+exports.ShellString = common.ShellString;
+
//@
//@ ### env['VAR_NAME']
-//@ Object containing environment variables (both getter and setter). Shortcut to process.env.
+//@ Object containing environment variables (both getter and setter). Shortcut
+//@ to process.env.
exports.env = process.env;
-//@include ./src/exec
-var _exec = require('./src/exec');
-exports.exec = common.wrap('exec', _exec, {notUnix:true});
-
-//@include ./src/chmod
-var _chmod = require('./src/chmod');
-exports.chmod = common.wrap('chmod', _chmod);
-
-//@include ./src/touch
-var _touch = require('./src/touch');
-exports.touch = common.wrap('touch', _touch);
-
-//@include ./src/set
-var _set = require('./src/set');
-exports.set = common.wrap('set', _set);
-
-
//@
-//@ ## Non-Unix commands
+//@ ### Pipes
//@
-
-//@include ./src/tempdir
-var _tempDir = require('./src/tempdir');
-exports.tempdir = common.wrap('tempdir', _tempDir);
-
-
-//@include ./src/error
-var _error = require('./src/error');
-exports.error = _error;
-
-
+//@ Examples:
+//@
+//@ ```javascript
+//@ grep('foo', 'file1.txt', 'file2.txt').sed(/o/g, 'a').to('output.txt');
+//@ echo('files with o\'s in the name:\n' + ls().grep('o'));
+//@ cat('test.js').exec('node'); // pipe to exec() call
+//@ ```
+//@
+//@ Commands can send their output to another command in a pipe-like fashion.
+//@ `sed`, `grep`, `cat`, `exec`, `to`, and `toEnd` can appear on the right-hand
+//@ side of a pipe. Pipes can be chained.
//@
//@ ## Configuration
@@ -139,6 +65,7 @@ exports.config = common.config;
//@
//@ ### config.silent
+//@
//@ Example:
//@
//@ ```javascript
@@ -154,20 +81,23 @@ exports.config = common.config;
//@
//@ ### config.fatal
+//@
//@ Example:
//@
//@ ```javascript
//@ require('shelljs/global');
//@ config.fatal = true; // or set('-e');
-//@ cp('this_file_does_not_exist', '/dev/null'); // dies here
+//@ cp('this_file_does_not_exist', '/dev/null'); // throws Error here
//@ /* more commands... */
//@ ```
//@
-//@ If `true` the script will die on errors. Default is `false`. This is
-//@ analogous to Bash's `set -e`
+//@ If `true` the script will throw a Javascript error when any shell.js
+//@ command encounters an error. Default is `false`. This is analogous to
+//@ Bash's `set -e`
//@
//@ ### config.verbose
+//@
//@ Example:
//@
//@ ```javascript
@@ -182,3 +112,41 @@ exports.config = common.config;
//@ cd dir/
//@ ls subdir/
//@ ```
+
+//@
+//@ ### config.globOptions
+//@
+//@ Example:
+//@
+//@ ```javascript
+//@ config.globOptions = {nodir: true};
+//@ ```
+//@
+//@ Use this value for calls to `glob.sync()` instead of the default options.
+
+//@
+//@ ### config.reset()
+//@
+//@ Example:
+//@
+//@ ```javascript
+//@ var shell = require('shelljs');
+//@ // Make changes to shell.config, and do stuff...
+//@ /* ... */
+//@ shell.config.reset(); // reset to original state
+//@ // Do more stuff, but with original settings
+//@ /* ... */
+//@ ```
+//@
+//@ Reset shell.config to the defaults:
+//@
+//@ ```javascript
+//@ {
+//@ fatal: false,
+//@ globOptions: {},
+//@ maxdepth: 255,
+//@ noglob: false,
+//@ silent: false,
+//@ verbose: false,
+//@ }
+//@ ```
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/cat.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/cat.js b/node_modules/shelljs/src/cat.js
index 5840b4e..a74a25c 100644
--- a/node_modules/shelljs/src/cat.js
+++ b/node_modules/shelljs/src/cat.js
@@ -1,6 +1,10 @@
var common = require('./common');
var fs = require('fs');
+common.register('cat', _cat, {
+ canReceivePipe: true,
+});
+
//@
//@ ### cat(file [, file ...])
//@ ### cat(file_array)
@@ -15,26 +19,22 @@ var fs = require('fs');
//@
//@ Returns a string containing the given file, or a concatenated string
//@ containing the files if more than one file is given (a new line character is
-//@ introduced between each file). Wildcard `*` accepted.
+//@ introduced between each file).
function _cat(options, files) {
- var cat = '';
-
- if (!files)
- common.error('no paths given');
+ var cat = common.readFromPipe();
- if (typeof files === 'string')
- files = [].slice.call(arguments, 1);
- // if it's array leave it as it is
+ if (!files && !cat) common.error('no paths given');
- files = common.expand(files);
+ files = [].slice.call(arguments, 1);
- files.forEach(function(file) {
- if (!fs.existsSync(file))
+ files.forEach(function (file) {
+ if (!fs.existsSync(file)) {
common.error('no such file or directory: ' + file);
+ }
cat += fs.readFileSync(file, 'utf8');
});
- return common.ShellString(cat);
+ return cat;
}
module.exports = _cat;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/cd.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/cd.js b/node_modules/shelljs/src/cd.js
index b7b9931..634ed83 100644
--- a/node_modules/shelljs/src/cd.js
+++ b/node_modules/shelljs/src/cd.js
@@ -1,28 +1,38 @@
var fs = require('fs');
var common = require('./common');
+common.register('cd', _cd, {});
+
//@
//@ ### cd([dir])
//@ Changes to directory `dir` for the duration of the script. Changes to home
//@ directory if no argument is supplied.
function _cd(options, dir) {
- if (!dir)
- dir = common.getUserHome();
+ if (!dir) dir = common.getUserHome();
if (dir === '-') {
- if (!common.state.previousDir)
+ if (!process.env.OLDPWD) {
common.error('could not find previous directory');
- else
- dir = common.state.previousDir;
+ } else {
+ dir = process.env.OLDPWD;
+ }
}
- if (!fs.existsSync(dir))
- common.error('no such file or directory: ' + dir);
-
- if (!fs.statSync(dir).isDirectory())
- common.error('not a directory: ' + dir);
-
- common.state.previousDir = process.cwd();
- process.chdir(dir);
+ try {
+ var curDir = process.cwd();
+ process.chdir(dir);
+ process.env.OLDPWD = curDir;
+ } catch (e) {
+ // something went wrong, let's figure out the error
+ var err;
+ try {
+ fs.statSync(dir); // if this succeeds, it must be some sort of file
+ err = 'not a directory: ' + dir;
+ } catch (e2) {
+ err = 'no such file or directory: ' + dir;
+ }
+ if (err) common.error(err);
+ }
+ return '';
}
module.exports = _cd;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[17/25] cordova-browser git commit: clean up linter errors
Posted by pu...@apache.org.
clean up linter errors
Project: http://git-wip-us.apache.org/repos/asf/cordova-browser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-browser/commit/4345045a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-browser/tree/4345045a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-browser/diff/4345045a
Branch: refs/heads/master
Commit: 4345045a0dfcfde9495e874d195cc5df4cb8c5c8
Parents: d7cdec3
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu May 4 17:22:56 2017 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu May 4 17:22:56 2017 -0700
----------------------------------------------------------------------
bin/template/cordova/Api.js | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/4345045a/bin/template/cordova/Api.js
----------------------------------------------------------------------
diff --git a/bin/template/cordova/Api.js b/bin/template/cordova/Api.js
index ac1060e..eb2d593 100644
--- a/bin/template/cordova/Api.js
+++ b/bin/template/cordova/Api.js
@@ -268,8 +268,6 @@ Api.prototype.removePlugin = function (plugin, uninstallOptions) {
// TODO: this should be done by plugin files uninstaller
shell.rm('-rf', path.resolve(self.root, 'Plugins', plugin.id));
});
-
- return Promise.resolve();
};
Api.prototype._getInstaller = function(type) {
@@ -278,7 +276,7 @@ Api.prototype._getInstaller = function(type) {
var installer = self._handler[type];
if(!installer) {
- console.log("unrecognized type " + type)
+ console.log("unrecognized type " + type);
return;
}
else {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[05/25] cordova-browser git commit: resolved merge issue
Posted by pu...@apache.org.
resolved merge issue
Project: http://git-wip-us.apache.org/repos/asf/cordova-browser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-browser/commit/ea7fdc41
Tree: http://git-wip-us.apache.org/repos/asf/cordova-browser/tree/ea7fdc41
Diff: http://git-wip-us.apache.org/repos/asf/cordova-browser/diff/ea7fdc41
Branch: refs/heads/master
Commit: ea7fdc41f8d7608d2b08427aa0faa5d79000ce42
Parents: 6281ea5 606f407
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Wed Apr 12 23:48:13 2017 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Wed Apr 12 23:48:13 2017 -0700
----------------------------------------------------------------------
bin/lib/create.js | 22 ++--------------------
1 file changed, 2 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/ea7fdc41/bin/lib/create.js
----------------------------------------------------------------------
diff --cc bin/lib/create.js
index a7bb099,2f77cc2..d1000ed
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@@ -28,38 -29,6 +28,21 @@@ var fs = require('fs')
module.exports.createProject = function(project_path,package_name,project_name){
+ console.log("ROOT = " + ROOT);
+ console.log("browser :: createProject",project_path,package_name,project_name);
+
+
+/*
+ // create the dest and the standard place for our api to live
+ // platforms/platformName/cordova/Api.js
+
- var apiSrcPath = __dirname; // default value
- console.log("apiSrcPath " + apiSrcPath);
- // does options contain the info we desire?
-
- var projectName = config ? config.name() : "HelloCordova";
-
- events.emit('log', 'Creating Cordova project for cordova-platform-test:');
++ // TODO: other platforms emit log info
++ events.emit('log', 'Creating Cordova project for cordova-browser:');
+ events.emit('log', '\tPath: ' + dest);
+ events.emit('log', '\tName: ' + projectName);
+
- shell.mkdir(dest);
-
- // move a copy of our api to the new project
- shell.cp('-r',apiSrcPath, dest);
-
- // move our node_modules
- var srcModulePath = path.join(__dirname,'../../../node_modules');
- console.log("srcModulePath = " + srcModulePath);
- shell.cp('-r',srcModulePath,path.join(dest,'cordova'));
-
- // I promise I will return
- return Promise.resolve(new Api(PLATFORM_NAME,dest,events));
+*/
+
var VERSION = fs.readFileSync(path.join(ROOT, 'VERSION'), 'utf-8');
// Set default values for path, package and name
@@@ -89,19 -55,27 +72,18 @@@
}
//copy required node_modules
- shjs.cp('-r', path.join(ROOT, 'node_modules'), path.join(project_path,'cordova'));
+ shell.cp('-r', path.join(ROOT, 'node_modules'), path.join(project_path,'cordova'));
//copy check_reqs file
- shjs.cp( path.join(ROOT, 'bin', 'lib', 'check_reqs.js'), path.join(project_path,'cordova', 'lib'));
+ shell.cp( path.join(ROOT, 'bin/lib/check_reqs.js'), path.join(project_path,'cordova/lib'));
//copy cordova js file
- shjs.cp('-r', path.join(ROOT, 'cordova-lib', 'cordova.js'), path.join(project_path,'www'));
+ shell.cp('-r', path.join(ROOT, 'cordova-lib', 'cordova.js'), path.join(project_path,'www'));
//copy cordova-js-src directory
- shjs.cp('-rf', path.join(ROOT, 'cordova-js-src'), path.join(project_path, 'platform_www'));
+ shell.cp('-rf', path.join(ROOT, 'cordova-js-src'), path.join(project_path, 'platform_www'));
//copy cordova directory
- shjs.cp('-r', path.join(ROOT, 'bin', 'templates', 'project', 'cordova'), project_path);
- [
- 'run',
- 'build',
- 'clean',
- 'version',
- ].forEach(function(f) {
- shjs.chmod(755, path.join(project_path, 'cordova', f));
- });
-
- return Q.resolve();
+ shell.cp('-r', path.join(ROOT, 'bin/template/cordova'), project_path);
-
+ return Promise.resolve();
};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[25/25] cordova-browser git commit: remove bundled dep on and move
shelljs to reasonable version
Posted by pu...@apache.org.
remove bundled dep on and move shelljs to reasonable version
Project: http://git-wip-us.apache.org/repos/asf/cordova-browser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-browser/commit/de5c08a3
Tree: http://git-wip-us.apache.org/repos/asf/cordova-browser/tree/de5c08a3
Diff: http://git-wip-us.apache.org/repos/asf/cordova-browser/diff/de5c08a3
Branch: refs/heads/master
Commit: de5c08a3d26c516088a242c9e36285fc57218287
Parents: adfd787
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu May 25 13:37:58 2017 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu May 25 13:37:58 2017 -0700
----------------------------------------------------------------------
node_modules/shelljs/LICENSE | 2 +-
node_modules/shelljs/README.md | 772 +++++++++++--------------------
node_modules/shelljs/bin/shjs | 22 +-
node_modules/shelljs/global.js | 11 +-
node_modules/shelljs/make.js | 9 +-
node_modules/shelljs/package.json | 117 ++---
node_modules/shelljs/shell.js | 197 ++++----
node_modules/shelljs/src/cat.js | 29 +-
node_modules/shelljs/src/cd.js | 39 +-
node_modules/shelljs/src/chmod.js | 114 +++--
node_modules/shelljs/src/common.js | 447 ++++--------------
node_modules/shelljs/src/cp.js | 286 +++++-------
node_modules/shelljs/src/dirs.js | 21 +-
node_modules/shelljs/src/echo.js | 24 +-
node_modules/shelljs/src/error.js | 10 +-
node_modules/shelljs/src/exec.js | 267 ++++-------
node_modules/shelljs/src/find.js | 30 +-
node_modules/shelljs/src/grep.js | 63 +--
node_modules/shelljs/src/ln.js | 55 +--
node_modules/shelljs/src/ls.js | 158 +++----
node_modules/shelljs/src/mkdir.js | 61 +--
node_modules/shelljs/src/mv.js | 67 +--
node_modules/shelljs/src/popd.js | 2 +-
node_modules/shelljs/src/pushd.js | 2 +-
node_modules/shelljs/src/pwd.js | 8 +-
node_modules/shelljs/src/rm.js | 127 ++---
node_modules/shelljs/src/sed.js | 83 +---
node_modules/shelljs/src/set.js | 55 ---
node_modules/shelljs/src/tempdir.js | 30 +-
node_modules/shelljs/src/test.js | 71 +--
node_modules/shelljs/src/to.js | 28 +-
node_modules/shelljs/src/toEnd.js | 27 +-
node_modules/shelljs/src/touch.js | 110 -----
node_modules/shelljs/src/which.js | 111 ++---
package.json | 4 +-
35 files changed, 1217 insertions(+), 2242 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/LICENSE
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/LICENSE b/node_modules/shelljs/LICENSE
index 0f0f119..1b35ee9 100644
--- a/node_modules/shelljs/LICENSE
+++ b/node_modules/shelljs/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2012, Artur Adib <ar...@gmail.com>
+Copyright (c) 2012, Artur Adib <aa...@mozilla.com>
All rights reserved.
You may use this project under the terms of the New BSD license as follows:
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/README.md
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/README.md b/node_modules/shelljs/README.md
index 91f110f..d08d13e 100644
--- a/node_modules/shelljs/README.md
+++ b/node_modules/shelljs/README.md
@@ -1,61 +1,19 @@
-# ShellJS - Unix shell commands for Node.js
+# ShellJS - Unix shell commands for Node.js [](http://travis-ci.org/arturadib/shelljs)
-[](https://gitter.im/shelljs/shelljs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
-[](https://travis-ci.org/shelljs/shelljs)
-[](https://ci.appveyor.com/project/shelljs/shelljs/branch/master)
-[](https://codecov.io/gh/shelljs/shelljs)
-[](https://www.npmjs.com/package/shelljs)
-[](https://www.npmjs.com/package/shelljs)
+ShellJS is a portable **(Windows/Linux/OS X)** implementation of Unix shell commands on top of the Node.js API. You can use it to eliminate your shell script's dependency on Unix while still keeping its familiar and powerful commands. You can also install it globally so you can run it from outside Node projects - say goodbye to those gnarly Bash scripts!
-ShellJS is a portable **(Windows/Linux/OS X)** implementation of Unix shell
-commands on top of the Node.js API. You can use it to eliminate your shell
-script's dependency on Unix while still keeping its familiar and powerful
-commands. You can also install it globally so you can run it from outside Node
-projects - say goodbye to those gnarly Bash scripts!
-
-ShellJS is proudly tested on every node release since `v0.11`!
-
-The project is [unit-tested](http://travis-ci.org/shelljs/shelljs) and battle-tested in projects like:
+The project is [unit-tested](http://travis-ci.org/arturadib/shelljs) and battled-tested in projects like:
+ [PDF.js](http://github.com/mozilla/pdf.js) - Firefox's next-gen PDF reader
+ [Firebug](http://getfirebug.com/) - Firefox's infamous debugger
-+ [JSHint](http://jshint.com) & [ESLint](http://eslint.org/) - popular JavaScript linters
++ [JSHint](http://jshint.com) - Most popular JavaScript linter
+ [Zepto](http://zeptojs.com) - jQuery-compatible JavaScript library for modern browsers
+ [Yeoman](http://yeoman.io/) - Web application stack and development tool
+ [Deployd.com](http://deployd.com) - Open source PaaS for quick API backend generation
-+ And [many more](https://npmjs.org/browse/depended/shelljs).
-
-If you have feedback, suggestions, or need help, feel free to post in our [issue
-tracker](https://github.com/shelljs/shelljs/issues).
-
-Think ShellJS is cool? Check out some related projects in our [Wiki
-page](https://github.com/shelljs/shelljs/wiki)!
-Upgrading from an older version? Check out our [breaking
-changes](https://github.com/shelljs/shelljs/wiki/Breaking-Changes) page to see
-what changes to watch out for while upgrading.
+and [many more](https://npmjs.org/browse/depended/shelljs).
-## Command line use
-
-If you just want cross platform UNIX commands, checkout our new project
-[shelljs/shx](https://github.com/shelljs/shx), a utility to expose `shelljs` to
-the command line.
-
-For example:
-
-```
-$ shx mkdir -p foo
-$ shx touch foo/bar.txt
-$ shx rm -rf foo
-```
-
-## A quick note about the docs
-
-For documentation on all the latest features, check out our
-[README](https://github.com/shelljs/shelljs). To read docs that are consistent
-with the latest release, check out [the npm
-page](https://www.npmjs.com/package/shelljs) or
-[shelljs.org](http://documentup.com/shelljs/shelljs).
+Connect with [@r2r](http://twitter.com/r2r) on Twitter for questions, suggestions, etc.
## Installing
@@ -65,253 +23,165 @@ Via npm:
$ npm install [-g] shelljs
```
+If the global option `-g` is specified, the binary `shjs` will be installed. This makes it possible to
+run ShellJS scripts much like any shell script from the command line, i.e. without requiring a `node_modules` folder:
+
+```bash
+$ shjs my_script
+```
+
+You can also just copy `shell.js` into your project's directory, and `require()` accordingly.
+
+
## Examples
+### JavaScript
+
```javascript
-var shell = require('shelljs');
+require('shelljs/global');
-if (!shell.which('git')) {
- shell.echo('Sorry, this script requires git');
- shell.exit(1);
+if (!which('git')) {
+ echo('Sorry, this script requires git');
+ exit(1);
}
// Copy files to release dir
-shell.rm('-rf', 'out/Release');
-shell.cp('-R', 'stuff/', 'out/Release');
+mkdir('-p', 'out/Release');
+cp('-R', 'stuff/*', 'out/Release');
// Replace macros in each .js file
-shell.cd('lib');
-shell.ls('*.js').forEach(function (file) {
- shell.sed('-i', 'BUILD_VERSION', 'v0.1.2', file);
- shell.sed('-i', /^.*REMOVE_THIS_LINE.*$/, '', file);
- shell.sed('-i', /.*REPLACE_LINE_WITH_MACRO.*\n/, shell.cat('macro.js'), file);
+cd('lib');
+ls('*.js').forEach(function(file) {
+ sed('-i', 'BUILD_VERSION', 'v0.1.2', file);
+ sed('-i', /.*REMOVE_THIS_LINE.*\n/, '', file);
+ sed('-i', /.*REPLACE_LINE_WITH_MACRO.*\n/, cat('macro.js'), file);
});
-shell.cd('..');
+cd('..');
// Run external tool synchronously
-if (shell.exec('git commit -am "Auto-commit"').code !== 0) {
- shell.echo('Error: Git commit failed');
- shell.exit(1);
+if (exec('git commit -am "Auto-commit"').code !== 0) {
+ echo('Error: Git commit failed');
+ exit(1);
}
```
-## Global vs. Local
-
-We no longer recommend using a global-import for ShellJS (i.e.
-`require('shelljs/global')`). While still supported for convenience, this
-pollutes the global namespace, and should therefore only be used with caution.
-
-Instead, we recommend a local import (standard for npm packages):
-
-```javascript
-var shell = require('shelljs');
-shell.echo('hello world');
-```
-
-<!-- DO NOT MODIFY BEYOND THIS POINT - IT'S AUTOMATICALLY GENERATED -->
+### CoffeeScript
+```coffeescript
+require 'shelljs/global'
-## Command reference
-
+if not which 'git'
+ echo 'Sorry, this script requires git'
+ exit 1
-All commands run synchronously, unless otherwise stated.
-All commands accept standard bash globbing characters (`*`, `?`, etc.),
-compatible with the [node glob module](https://github.com/isaacs/node-glob).
+# Copy files to release dir
+mkdir '-p', 'out/Release'
+cp '-R', 'stuff/*', 'out/Release'
-For less-commonly used commands and features, please check out our [wiki
-page](https://github.com/shelljs/shelljs/wiki).
-
-
-### cat(file [, file ...])
-### cat(file_array)
-
-Examples:
+# Replace macros in each .js file
+cd 'lib'
+for file in ls '*.js'
+ sed '-i', 'BUILD_VERSION', 'v0.1.2', file
+ sed '-i', /.*REMOVE_THIS_LINE.*\n/, '', file
+ sed '-i', /.*REPLACE_LINE_WITH_MACRO.*\n/, cat 'macro.js', file
+cd '..'
-```javascript
-var str = cat('file*.txt');
-var str = cat('file1', 'file2');
-var str = cat(['file1', 'file2']); // same as above
+# Run external tool synchronously
+if (exec 'git commit -am "Auto-commit"').code != 0
+ echo 'Error: Git commit failed'
+ exit 1
```
-Returns a string containing the given file, or a concatenated string
-containing the files if more than one file is given (a new line character is
-introduced between each file).
-
-
-### cd([dir])
-Changes to directory `dir` for the duration of the script. Changes to home
-directory if no argument is supplied.
-
-
-### chmod([options,] octal_mode || octal_string, file)
-### chmod([options,] symbolic_mode, file)
+## Global vs. Local
-Available options:
+The example above uses the convenience script `shelljs/global` to reduce verbosity. If polluting your global namespace is not desirable, simply require `shelljs`.
-+ `-v`: output a diagnostic for every file processed
-+ `-c`: like verbose but report only when a change is made
-+ `-R`: change files and directories recursively
-
-Examples:
+Example:
```javascript
-chmod(755, '/Users/brandon');
-chmod('755', '/Users/brandon'); // same as above
-chmod('u+x', '/Users/brandon');
-chmod('-R', 'a-w', '/Users/brandon');
+var shell = require('shelljs');
+shell.echo('hello world');
```
-Alters the permissions of a file or directory by either specifying the
-absolute permissions in octal form or expressing the changes in symbols.
-This command tries to mimic the POSIX behavior as much as possible.
-Notable exceptions:
+## Make tool
-+ In symbolic modes, 'a-r' and '-r' are identical. No consideration is
- given to the umask.
-+ There is no "quiet" option since default behavior is to run silent.
+A convenience script `shelljs/make` is also provided to mimic the behavior of a Unix Makefile. In this case all shell objects are global, and command line arguments will cause the script to execute only the corresponding function in the global `target` object. To avoid redundant calls, target functions are executed only once per script.
+Example (CoffeeScript):
-### cp([options,] source [, source ...], dest)
-### cp([options,] source_array, dest)
-Available options:
+```coffeescript
+require 'shelljs/make'
-+ `-f`: force (default behavior)
-+ `-n`: no-clobber
-+ `-u`: only copy if source is newer than dest
-+ `-r`, `-R`: recursive
-+ `-L`: follow symlinks
-+ `-P`: don't follow symlinks
+target.all = ->
+ target.bundle()
+ target.docs()
-Examples:
+target.bundle = ->
+ cd __dirname
+ mkdir 'build'
+ cd 'lib'
+ (cat '*.js').to '../build/output.js'
-```javascript
-cp('file1', 'dir1');
-cp('-R', 'path/to/dir/', '~/newCopy/');
-cp('-Rf', '/tmp/*', '/usr/local/*', '/home/tmp');
-cp('-Rf', ['/tmp/*', '/usr/local/*'], '/home/tmp'); // same as above
+target.docs = ->
+ cd __dirname
+ mkdir 'docs'
+ cd 'lib'
+ for file in ls '*.js'
+ text = grep '//@', file # extract special comments
+ text.replace '//@', '' # remove comment tags
+ text.to 'docs/my_docs.md'
```
-Copies files.
+To run the target `all`, call the above script without arguments: `$ node make`. To run the target `docs`: `$ node make docs`.
-
-### pushd([options,] [dir | '-N' | '+N'])
-
-Available options:
-
-+ `-n`: Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated.
-
-Arguments:
-
-+ `dir`: Makes the current working directory be the top of the stack, and then executes the equivalent of `cd dir`.
-+ `+N`: Brings the Nth directory (counting from the left of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.
-+ `-N`: Brings the Nth directory (counting from the right of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.
-
-Examples:
+You can also pass arguments to your targets by using the `--` separator. For example, to pass `arg1` and `arg2` to a target `bundle`, do `$ node make bundle -- arg1 arg2`:
```javascript
-// process.cwd() === '/usr'
-pushd('/etc'); // Returns /etc /usr
-pushd('+1'); // Returns /usr /etc
-```
-
-Save the current directory on the top of the directory stack and then cd to `dir`. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack.
-
-### popd([options,] ['-N' | '+N'])
-
-Available options:
-
-+ `-n`: Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated.
-
-Arguments:
+require('shelljs/make');
-+ `+N`: Removes the Nth directory (counting from the left of the list printed by dirs), starting with zero.
-+ `-N`: Removes the Nth directory (counting from the right of the list printed by dirs), starting with zero.
-
-Examples:
-
-```javascript
-echo(process.cwd()); // '/usr'
-pushd('/etc'); // '/etc /usr'
-echo(process.cwd()); // '/etc'
-popd(); // '/usr'
-echo(process.cwd()); // '/usr'
+target.bundle = function(argsArray) {
+ // argsArray = ['arg1', 'arg2']
+ /* ... */
+}
```
-When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack.
-
-### dirs([options | '+N' | '-N'])
-
-Available options:
-+ `-c`: Clears the directory stack by deleting all of the elements.
-
-Arguments:
-
-+ `+N`: Displays the Nth directory (counting from the left of the list printed by dirs when invoked without options), starting with zero.
-+ `-N`: Displays the Nth directory (counting from the right of the list printed by dirs when invoked without options), starting with zero.
+<!-- DO NOT MODIFY BEYOND THIS POINT - IT'S AUTOMATICALLY GENERATED -->
-Display the list of currently remembered directories. Returns an array of paths in the stack, or a single path if +N or -N was specified.
-See also: pushd, popd
+## Command reference
-### echo([options,] string [, string ...])
-Available options:
+All commands run synchronously, unless otherwise stated.
-+ `-e`: interpret backslash escapes (default)
-Examples:
+### cd('dir')
+Changes to directory `dir` for the duration of the script
-```javascript
-echo('hello world');
-var str = echo('hello world');
-```
-Prints string to stdout, and returns string with additional utility methods
-like `.to()`.
+### pwd()
+Returns the current directory.
-### exec(command [, options] [, callback])
-Available options (all `false` by default):
+### ls([options ,] path [,path ...])
+### ls([options ,] path_array)
+Available options:
-+ `async`: Asynchronous execution. If a callback is provided, it will be set to
- `true`, regardless of the passed value.
-+ `silent`: Do not echo program output to console.
-+ and any option available to Node.js's
- [child_process.exec()](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback)
++ `-R`: recursive
++ `-A`: all files (include files beginning with `.`, except for `.` and `..`)
Examples:
```javascript
-var version = exec('node --version', {silent:true}).stdout;
-
-var child = exec('some_long_running_process', {async:true});
-child.stdout.on('data', function(data) {
- /* ... do something with data ... */
-});
-
-exec('some_long_running_process', function(code, stdout, stderr) {
- console.log('Exit code:', code);
- console.log('Program output:', stdout);
- console.log('Program stderr:', stderr);
-});
+ls('projs/*.js');
+ls('-R', '/users/me', '/tmp');
+ls('-R', ['/users/me', '/tmp']); // same as above
```
-Executes the given `command` _synchronously_, unless otherwise specified. When in synchronous
-mode, this returns a ShellString (compatible with ShellJS v0.6.x, which returns an object
-of the form `{ code:..., stdout:... , stderr:... }`). Otherwise, this returns the child process
-object, and the `callback` gets the arguments `(code, stdout, stderr)`.
-
-Not seeing the behavior you want? `exec()` runs everything through `sh`
-by default (or `cmd.exe` on Windows), which differs from `bash`. If you
-need bash-specific behavior, try out the `{shell: 'path/to/bash'}` option.
-
-**Note:** For long-lived processes, it's best to run `exec()` asynchronously as
-the current synchronous implementation uses a lot of CPU. This should be getting
-fixed soon.
+Returns array of files in the given path, or in current directory if no path provided.
-### find(path [, path ...])
+### find(path [,path ...])
### find(path_array)
Examples:
@@ -327,140 +197,138 @@ The main difference from `ls('-R', path)` is that the resulting file names
include the base directories, e.g. `lib/resources/file1` instead of just `file1`.
-### grep([options,] regex_filter, file [, file ...])
-### grep([options,] regex_filter, file_array)
+### cp([options ,] source [,source ...], dest)
+### cp([options ,] source_array, dest)
Available options:
-+ `-v`: Inverse the sense of the regex and print the lines not matching the criteria.
-+ `-l`: Print only filenames of matching files
++ `-f`: force
++ `-r, -R`: recursive
Examples:
```javascript
-grep('-v', 'GLOBAL_VARIABLE', '*.js');
-grep('GLOBAL_VARIABLE', '*.js');
+cp('file1', 'dir1');
+cp('-Rf', '/tmp/*', '/usr/local/*', '/home/tmp');
+cp('-Rf', ['/tmp/*', '/usr/local/*'], '/home/tmp'); // same as above
```
-Reads input string from given files and returns a string containing all lines of the
-file that match the given `regex_filter`.
+Copies files. The wildcard `*` is accepted.
-### head([{'-n': \<num\>},] file [, file ...])
-### head([{'-n': \<num\>},] file_array)
+### rm([options ,] file [, file ...])
+### rm([options ,] file_array)
Available options:
-+ `-n <num>`: Show the first `<num>` lines of the files
++ `-f`: force
++ `-r, -R`: recursive
Examples:
```javascript
-var str = head({'-n': 1}, 'file*.txt');
-var str = head('file1', 'file2');
-var str = head(['file1', 'file2']); // same as above
+rm('-rf', '/tmp/*');
+rm('some_file.txt', 'another_file.txt');
+rm(['some_file.txt', 'another_file.txt']); // same as above
```
-Read the start of a file.
+Removes files. The wildcard `*` is accepted.
-### ln([options,] source, dest)
+### mv(source [, source ...], dest')
+### mv(source_array, dest')
Available options:
-+ `-s`: symlink
-+ `-f`: force
++ `f`: force
Examples:
```javascript
-ln('file', 'newlink');
-ln('-sf', 'file', 'existing');
+mv('-f', 'file', 'dir/');
+mv('file1', 'file2', 'dir/');
+mv(['file1', 'file2'], 'dir/'); // same as above
```
-Links source to dest. Use -f to force the link, should dest already exist.
+Moves files. The wildcard `*` is accepted.
-### ls([options,] [path, ...])
-### ls([options,] path_array)
+### mkdir([options ,] dir [, dir ...])
+### mkdir([options ,] dir_array)
Available options:
-+ `-R`: recursive
-+ `-A`: all files (include files beginning with `.`, except for `.` and `..`)
-+ `-L`: follow symlinks
-+ `-d`: list directories themselves, not their contents
-+ `-l`: list objects representing each file, each with fields containing `ls
- -l` output fields. See
- [fs.Stats](https://nodejs.org/api/fs.html#fs_class_fs_stats)
- for more info
++ `p`: full path (will create intermediate dirs if necessary)
Examples:
```javascript
-ls('projs/*.js');
-ls('-R', '/users/me', '/tmp');
-ls('-R', ['/users/me', '/tmp']); // same as above
-ls('-l', 'file.txt'); // { name: 'file.txt', mode: 33188, nlink: 1, ...}
+mkdir('-p', '/tmp/a/b/c/d', '/tmp/e/f/g');
+mkdir('-p', ['/tmp/a/b/c/d', '/tmp/e/f/g']); // same as above
```
-Returns array of files in the given path, or in current directory if no path provided.
+Creates directories.
-### mkdir([options,] dir [, dir ...])
-### mkdir([options,] dir_array)
-Available options:
+### test(expression)
+Available expression primaries:
-+ `-p`: full path (will create intermediate dirs if necessary)
++ `'-b', 'path'`: true if path is a block device
++ `'-c', 'path'`: true if path is a character device
++ `'-d', 'path'`: true if path is a directory
++ `'-e', 'path'`: true if path exists
++ `'-f', 'path'`: true if path is a regular file
++ `'-L', 'path'`: true if path is a symbolic link
++ `'-p', 'path'`: true if path is a pipe (FIFO)
++ `'-S', 'path'`: true if path is a socket
Examples:
```javascript
-mkdir('-p', '/tmp/a/b/c/d', '/tmp/e/f/g');
-mkdir('-p', ['/tmp/a/b/c/d', '/tmp/e/f/g']); // same as above
+if (test('-d', path)) { /* do something with dir */ };
+if (!test('-f', path)) continue; // skip if it's a regular file
```
-Creates directories.
-
+Evaluates expression using the available primaries and returns corresponding value.
-### mv([options ,] source [, source ...], dest')
-### mv([options ,] source_array, dest')
-Available options:
-+ `-f`: force (default behavior)
-+ `-n`: no-clobber
+### cat(file [, file ...])
+### cat(file_array)
Examples:
```javascript
-mv('-n', 'file', 'dir/');
-mv('file1', 'file2', 'dir/');
-mv(['file1', 'file2'], 'dir/'); // same as above
+var str = cat('file*.txt');
+var str = cat('file1', 'file2');
+var str = cat(['file1', 'file2']); // same as above
```
-Moves files.
+Returns a string containing the given file, or a concatenated string
+containing the files if more than one file is given (a new line character is
+introduced between each file). Wildcard `*` accepted.
-### pwd()
-Returns the current directory.
+### 'string'.to(file)
+Examples:
-### rm([options,] file [, file ...])
-### rm([options,] file_array)
-Available options:
+```javascript
+cat('input.txt').to('output.txt');
+```
+
+Analogous to the redirection operator `>` in Unix, but works with JavaScript strings (such as
+those returned by `cat`, `grep`, etc). _Like Unix redirections, `to()` will overwrite any existing file!_
-+ `-f`: force
-+ `-r, -R`: recursive
+
+### 'string'.toEnd(file)
Examples:
```javascript
-rm('-rf', '/tmp/*');
-rm('some_file.txt', 'another_file.txt');
-rm(['some_file.txt', 'another_file.txt']); // same as above
+cat('input.txt').toEnd('output.txt');
```
-Removes files.
+Analogous to the redirect-and-append operator `>>` in Unix, but works with JavaScript strings (such as
+those returned by `cat`, `grep`, etc).
-### sed([options,] search_regex, replacement, file [, file ...])
-### sed([options,] search_regex, replacement, file_array)
+### sed([options ,] search_regex, replacement, file)
Available options:
+ `-i`: Replace contents of 'file' in-place. _Note that no backups will be created!_
@@ -472,231 +340,219 @@ sed('-i', 'PROGRAM_VERSION', 'v0.1.3', 'source.js');
sed(/.*DELETE_THIS_LINE.*\n/, '', 'source.js');
```
-Reads an input string from `files` and performs a JavaScript `replace()` on the input
+Reads an input string from `file` and performs a JavaScript `replace()` on the input
using the given search regex and replacement string or function. Returns the new string after replacement.
-Note:
-
-Like unix `sed`, ShellJS `sed` supports capture groups. Capture groups are specified
-using the `$n` syntax:
-```javascript
-sed(/(\w+)\s(\w+)/, '$2, $1', 'file.txt');
-```
-
-
-### set(options)
+### grep([options ,] regex_filter, file [, file ...])
+### grep([options ,] regex_filter, file_array)
Available options:
-+ `+/-e`: exit upon error (`config.fatal`)
-+ `+/-v`: verbose: show all commands (`config.verbose`)
-+ `+/-f`: disable filename expansion (globbing)
++ `-v`: Inverse the sense of the regex and print the lines not matching the criteria.
Examples:
```javascript
-set('-e'); // exit upon first error
-set('+e'); // this undoes a "set('-e')"
+grep('-v', 'GLOBAL_VARIABLE', '*.js');
+grep('GLOBAL_VARIABLE', '*.js');
```
-Sets global configuration variables
-
+Reads input string from given files and returns a string containing all lines of the
+file that match the given `regex_filter`. Wildcard `*` accepted.
-### sort([options,] file [, file ...])
-### sort([options,] file_array)
-Available options:
-+ `-r`: Reverse the result of comparisons
-+ `-n`: Compare according to numerical value
+### which(command)
Examples:
```javascript
-sort('foo.txt', 'bar.txt');
-sort('-r', 'foo.txt');
+var nodeExec = which('node');
```
-Return the contents of the files, sorted line-by-line. Sorting multiple
-files mixes their content, just like unix sort does.
-
+Searches for `command` in the system's PATH. On Windows looks for `.exe`, `.cmd`, and `.bat` extensions.
+Returns string containing the absolute path to the command.
-### tail([{'-n': \<num\>},] file [, file ...])
-### tail([{'-n': \<num\>},] file_array)
-Available options:
-+ `-n <num>`: Show the last `<num>` lines of the files
+### echo(string [,string ...])
Examples:
```javascript
-var str = tail({'-n': 1}, 'file*.txt');
-var str = tail('file1', 'file2');
-var str = tail(['file1', 'file2']); // same as above
+echo('hello world');
+var str = echo('hello world');
```
-Read the end of a file.
-
-
-### tempdir()
+Prints string to stdout, and returns string with additional utility methods
+like `.to()`.
-Examples:
-```javascript
-var tmp = tempdir(); // "/tmp" for most *nix platforms
-```
+### pushd([options,] [dir | '-N' | '+N'])
-Searches and returns string containing a writeable, platform-dependent temporary directory.
-Follows Python's [tempfile algorithm](http://docs.python.org/library/tempfile.html#tempfile.tempdir).
+Available options:
++ `-n`: Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated.
-### test(expression)
-Available expression primaries:
+Arguments:
-+ `'-b', 'path'`: true if path is a block device
-+ `'-c', 'path'`: true if path is a character device
-+ `'-d', 'path'`: true if path is a directory
-+ `'-e', 'path'`: true if path exists
-+ `'-f', 'path'`: true if path is a regular file
-+ `'-L', 'path'`: true if path is a symbolic link
-+ `'-p', 'path'`: true if path is a pipe (FIFO)
-+ `'-S', 'path'`: true if path is a socket
++ `dir`: Makes the current working directory be the top of the stack, and then executes the equivalent of `cd dir`.
++ `+N`: Brings the Nth directory (counting from the left of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.
++ `-N`: Brings the Nth directory (counting from the right of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.
Examples:
```javascript
-if (test('-d', path)) { /* do something with dir */ };
-if (!test('-f', path)) continue; // skip if it's a regular file
+// process.cwd() === '/usr'
+pushd('/etc'); // Returns /etc /usr
+pushd('+1'); // Returns /usr /etc
```
-Evaluates expression using the available primaries and returns corresponding value.
-
-
-### ShellString.prototype.to(file)
+Save the current directory on the top of the directory stack and then cd to `dir`. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack.
-Examples:
+### popd([options,] ['-N' | '+N'])
-```javascript
-cat('input.txt').to('output.txt');
-```
+Available options:
-Analogous to the redirection operator `>` in Unix, but works with
-ShellStrings (such as those returned by `cat`, `grep`, etc). _Like Unix
-redirections, `to()` will overwrite any existing file!_
++ `-n`: Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated.
+Arguments:
-### ShellString.prototype.toEnd(file)
++ `+N`: Removes the Nth directory (counting from the left of the list printed by dirs), starting with zero.
++ `-N`: Removes the Nth directory (counting from the right of the list printed by dirs), starting with zero.
Examples:
```javascript
-cat('input.txt').toEnd('output.txt');
+echo(process.cwd()); // '/usr'
+pushd('/etc'); // '/etc /usr'
+echo(process.cwd()); // '/etc'
+popd(); // '/usr'
+echo(process.cwd()); // '/usr'
```
-Analogous to the redirect-and-append operator `>>` in Unix, but works with
-ShellStrings (such as those returned by `cat`, `grep`, etc).
+When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack.
+### dirs([options | '+N' | '-N'])
-### touch([options,] file [, file ...])
-### touch([options,] file_array)
Available options:
-+ `-a`: Change only the access time
-+ `-c`: Do not create any files
-+ `-m`: Change only the modification time
-+ `-d DATE`: Parse DATE and use it instead of current time
-+ `-r FILE`: Use FILE's times instead of current time
++ `-c`: Clears the directory stack by deleting all of the elements.
-Examples:
+Arguments:
-```javascript
-touch('source.js');
-touch('-c', '/path/to/some/dir/source.js');
-touch({ '-r': FILE }, '/path/to/some/dir/source.js');
-```
++ `+N`: Displays the Nth directory (counting from the left of the list printed by dirs when invoked without options), starting with zero.
++ `-N`: Displays the Nth directory (counting from the right of the list printed by dirs when invoked without options), starting with zero.
+
+Display the list of currently remembered directories. Returns an array of paths in the stack, or a single path if +N or -N was specified.
-Update the access and modification times of each FILE to the current time.
-A FILE argument that does not exist is created empty, unless -c is supplied.
-This is a partial implementation of *[touch(1)](http://linux.die.net/man/1/touch)*.
+See also: pushd, popd
-### uniq([options,] [input, [output]])
+### ln(options, source, dest)
+### ln(source, dest)
Available options:
-+ `-i`: Ignore case while comparing
-+ `-c`: Prefix lines by the number of occurrences
-+ `-d`: Only print duplicate lines, one for each group of identical lines
++ `s`: symlink
++ `f`: force
Examples:
```javascript
-uniq('foo.txt');
-uniq('-i', 'foo.txt');
-uniq('-cd', 'foo.txt', 'bar.txt');
+ln('file', 'newlink');
+ln('-sf', 'file', 'existing');
```
-Filter adjacent matching lines from input
+Links source to dest. Use -f to force the link, should dest already exist.
-### which(command)
+### exit(code)
+Exits the current process with the given exit code.
+
+### env['VAR_NAME']
+Object containing environment variables (both getter and setter). Shortcut to process.env.
+
+### exec(command [, options] [, callback])
+Available options (all `false` by default):
+
++ `async`: Asynchronous execution. Defaults to true if a callback is provided.
++ `silent`: Do not echo program output to console.
Examples:
```javascript
-var nodeExec = which('node');
-```
+var version = exec('node --version', {silent:true}).output;
-Searches for `command` in the system's PATH. On Windows, this uses the
-`PATHEXT` variable to append the extension if it's not already executable.
-Returns string containing the absolute path to the command.
+var child = exec('some_long_running_process', {async:true});
+child.stdout.on('data', function(data) {
+ /* ... do something with data ... */
+});
+exec('some_long_running_process', function(code, output) {
+ console.log('Exit code:', code);
+ console.log('Program output:', output);
+});
+```
-### exit(code)
-Exits the current process with the given exit code.
+Executes the given `command` _synchronously_, unless otherwise specified.
+When in synchronous mode returns the object `{ code:..., output:... }`, containing the program's
+`output` (stdout + stderr) and its exit `code`. Otherwise returns the child process object, and
+the `callback` gets the arguments `(code, output)`.
+
+**Note:** For long-lived processes, it's best to run `exec()` asynchronously as
+the current synchronous implementation uses a lot of CPU. This should be getting
+fixed soon.
-### error()
-Tests if error occurred in the last command. Returns a truthy value if an
-error returned and a falsy value otherwise.
-**Note**: do not rely on the
-return value to be an error message. If you need the last error message, use
-the `.stderr` attribute from the last command's return value instead.
+### chmod(octal_mode || octal_string, file)
+### chmod(symbolic_mode, file)
+Available options:
-### ShellString(str)
++ `-v`: output a diagnostic for every file processed
++ `-c`: like verbose but report only when a change is made
++ `-R`: change files and directories recursively
Examples:
```javascript
-var foo = ShellString('hello world');
+chmod(755, '/Users/brandon');
+chmod('755', '/Users/brandon'); // same as above
+chmod('u+x', '/Users/brandon');
```
-Turns a regular string into a string-like object similar to what each
-command returns. This has special methods, like `.to()` and `.toEnd()`
+Alters the permissions of a file or directory by either specifying the
+absolute permissions in octal form or expressing the changes in symbols.
+This command tries to mimic the POSIX behavior as much as possible.
+Notable exceptions:
+
++ In symbolic modes, 'a-r' and '-r' are identical. No consideration is
+ given to the umask.
++ There is no "quiet" option since default behavior is to run silent.
-### env['VAR_NAME']
-Object containing environment variables (both getter and setter). Shortcut
-to process.env.
+## Non-Unix commands
-### Pipes
+
+### tempdir()
Examples:
```javascript
-grep('foo', 'file1.txt', 'file2.txt').sed(/o/g, 'a').to('output.txt');
-echo('files with o\'s in the name:\n' + ls().grep('o'));
-cat('test.js').exec('node'); // pipe to exec() call
+var tmp = tempdir(); // "/tmp" for most *nix platforms
```
-Commands can send their output to another command in a pipe-like fashion.
-`sed`, `grep`, `cat`, `exec`, `to`, and `toEnd` can appear on the right-hand
-side of a pipe. Pipes can be chained.
+Searches and returns string containing a writeable, platform-dependent temporary directory.
+Follows Python's [tempfile algorithm](http://docs.python.org/library/tempfile.html#tempfile.tempdir).
+
+
+### error()
+Tests if error occurred in the last command. Returns `null` if no error occurred,
+otherwise returns string explaining the error
+
## Configuration
### config.silent
-
Example:
```javascript
@@ -711,75 +567,13 @@ Suppresses all command output if `true`, except for `echo()` calls.
Default is `false`.
### config.fatal
-
Example:
```javascript
require('shelljs/global');
-config.fatal = true; // or set('-e');
-cp('this_file_does_not_exist', '/dev/null'); // throws Error here
+config.fatal = true;
+cp('this_file_does_not_exist', '/dev/null'); // dies here
/* more commands... */
```
-If `true` the script will throw a Javascript error when any shell.js
-command encounters an error. Default is `false`. This is analogous to
-Bash's `set -e`
-
-### config.verbose
-
-Example:
-
-```javascript
-config.verbose = true; // or set('-v');
-cd('dir/');
-ls('subdir/');
-```
-
-Will print each command as follows:
-
-```
-cd dir/
-ls subdir/
-```
-
-### config.globOptions
-
-Example:
-
-```javascript
-config.globOptions = {nodir: true};
-```
-
-Use this value for calls to `glob.sync()` instead of the default options.
-
-### config.reset()
-
-Example:
-
-```javascript
-var shell = require('shelljs');
-// Make changes to shell.config, and do stuff...
-/* ... */
-shell.config.reset(); // reset to original state
-// Do more stuff, but with original settings
-/* ... */
-```
-
-Reset shell.config to the defaults:
-
-```javascript
-{
- fatal: false,
- globOptions: {},
- maxdepth: 255,
- noglob: false,
- silent: false,
- verbose: false,
-}
-```
-
-## Team
-
-| [](https://github.com/nfischer) | [](http://github.com/freitagbr) |
-|:---:|:---:|
-| [Nate Fischer](https://github.com/nfischer) | [Brandon Freitag](http://github.com/freitagbr) |
+If `true` the script will die on errors. Default is `false`.
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/bin/shjs
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/bin/shjs b/node_modules/shelljs/bin/shjs
index 75ca58b..d239a7a 100755
--- a/node_modules/shelljs/bin/shjs
+++ b/node_modules/shelljs/bin/shjs
@@ -32,8 +32,20 @@ for (var i = 0, l = args.length; i < l; i++) {
}
}
-var path = require('path');
-var extensions = require('interpret').extensions;
-var rechoir = require('rechoir');
-rechoir.prepare(extensions, scriptName);
-require(require.resolve(path.resolve(process.cwd(), scriptName)));
+if (scriptName.match(/\.coffee$/)) {
+ //
+ // CoffeeScript
+ //
+ if (which('coffee')) {
+ exec('coffee ' + scriptName + ' ' + args.join(' '), { async: true });
+ } else {
+ console.log('ShellJS: CoffeeScript interpreter not found');
+ console.log();
+ process.exit(1);
+ }
+} else {
+ //
+ // JavaScript
+ //
+ exec('node ' + scriptName + ' ' + args.join(' '), { async: true });
+}
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/global.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/global.js b/node_modules/shelljs/global.js
index b232e66..97f0033 100644
--- a/node_modules/shelljs/global.js
+++ b/node_modules/shelljs/global.js
@@ -1,12 +1,3 @@
-/* eslint no-extend-native: 0 */
var shell = require('./shell.js');
-var common = require('./src/common');
-Object.keys(shell).forEach(function (cmd) {
+for (var cmd in shell)
global[cmd] = shell[cmd];
-});
-
-var _to = require('./src/to');
-String.prototype.to = common.wrap('to', _to);
-
-var _toEnd = require('./src/toEnd');
-String.prototype.toEnd = common.wrap('toEnd', _toEnd);
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/make.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/make.js b/node_modules/shelljs/make.js
index a8438c8..f78b4cf 100644
--- a/node_modules/shelljs/make.js
+++ b/node_modules/shelljs/make.js
@@ -31,11 +31,10 @@ setTimeout(function() {
// Wrap it
global.target[t] = function() {
- if (!oldTarget.done){
- oldTarget.done = true;
- oldTarget.result = oldTarget.apply(oldTarget, arguments);
- }
- return oldTarget.result;
+ if (oldTarget.done)
+ return;
+ oldTarget.done = true;
+ return oldTarget.apply(oldTarget, arguments);
};
})(t, global.target[t]);
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/package.json
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/package.json b/node_modules/shelljs/package.json
index 7569f63..e8fd670 100644
--- a/node_modules/shelljs/package.json
+++ b/node_modules/shelljs/package.json
@@ -1,123 +1,78 @@
{
"_args": [
[
- "shelljs@*",
+ "shelljs@^0.5.3",
"/Repos/cordova/cordova-browser"
]
],
- "_from": "shelljs@*",
- "_id": "shelljs@0.7.7",
+ "_from": "shelljs@>=0.5.3 <0.6.0",
+ "_id": "shelljs@0.5.3",
"_inCache": true,
"_installable": true,
"_location": "/shelljs",
- "_nodeVersion": "6.7.0",
- "_npmOperationalInternal": {
- "host": "packages-18-east.internal.npmjs.com",
- "tmp": "tmp/shelljs-0.7.7.tgz_1489041432003_0.056656441651284695"
- },
+ "_nodeVersion": "1.2.0",
"_npmUser": {
- "email": "ntfschr@gmail.com",
- "name": "nfischer"
+ "email": "arturadib@gmail.com",
+ "name": "artur"
},
- "_npmVersion": "3.10.8",
+ "_npmVersion": "2.5.1",
"_phantomChildren": {},
"_requested": {
"name": "shelljs",
- "raw": "shelljs@*",
- "rawSpec": "*",
+ "raw": "shelljs@^0.5.3",
+ "rawSpec": "^0.5.3",
"scope": null,
- "spec": "*",
+ "spec": ">=0.5.3 <0.6.0",
"type": "range"
},
"_requiredBy": [
- "/"
+ "/",
+ "/cordova-common"
],
- "_resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.7.tgz",
- "_shasum": "b2f5c77ef97148f4b4f6e22682e10bba8667cff1",
+ "_resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.5.3.tgz",
+ "_shasum": "c54982b996c76ef0c1e6b59fbdc5825f5b713113",
"_shrinkwrap": null,
- "_spec": "shelljs@*",
+ "_spec": "shelljs@^0.5.3",
"_where": "/Repos/cordova/cordova-browser",
+ "author": {
+ "email": "arturadib@gmail.com",
+ "name": "Artur Adib"
+ },
"bin": {
"shjs": "./bin/shjs"
},
"bugs": {
- "url": "https://github.com/shelljs/shelljs/issues"
- },
- "contributors": [
- {
- "name": "Nate Fischer",
- "email": "ntfschr@gmail.com",
- "url": "https://github.com/nfischer"
- },
- {
- "name": "Brandon Freitag",
- "email": "freitagbr@gmail.com",
- "url": "https://github.com/freitagbr"
- }
- ],
- "dependencies": {
- "glob": "^7.0.0",
- "interpret": "^1.0.0",
- "rechoir": "^0.6.2"
+ "url": "https://github.com/arturadib/shelljs/issues"
},
+ "dependencies": {},
"description": "Portable Unix shell commands for Node.js",
"devDependencies": {
- "ava": "^0.16.0",
- "codecov": "^1.0.1",
- "coffee-script": "^1.10.0",
- "eslint": "^2.0.0",
- "eslint-config-airbnb-base": "^3.0.0",
- "eslint-plugin-import": "^1.11.1",
- "nyc": "^10.0.0",
- "shelljs-changelog": "^0.2.0",
- "shelljs-release": "^0.2.0",
- "shx": "^0.2.0",
- "travis-check-changes": "^0.2.0"
+ "jshint": "~2.1.11"
},
"directories": {},
"dist": {
- "shasum": "b2f5c77ef97148f4b4f6e22682e10bba8667cff1",
- "tarball": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.7.tgz"
+ "shasum": "c54982b996c76ef0c1e6b59fbdc5825f5b713113",
+ "tarball": "https://registry.npmjs.org/shelljs/-/shelljs-0.5.3.tgz"
},
"engines": {
- "iojs": "*",
- "node": ">=0.11.0"
+ "node": ">=0.8.0"
},
- "files": [
- "bin",
- "commands.js",
- "global.js",
- "make.js",
- "plugin.js",
- "shell.js",
- "src"
- ],
- "gitHead": "95638cc773390920a446e383c40ed8104c7d211d",
- "homepage": "http://github.com/shelljs/shelljs",
+ "gitHead": "22d0975040b9b8234755dc6e692d6869436e8485",
+ "homepage": "http://github.com/arturadib/shelljs",
"keywords": [
- "bash",
"jake",
"make",
"makefile",
"shell",
- "shelljs",
"synchronous",
"unix"
],
- "license": "BSD-3-Clause",
+ "license": "BSD*",
"main": "./shell.js",
"maintainers": [
{
"name": "artur",
"email": "arturadib@gmail.com"
- },
- {
- "name": "freitagbr",
- "email": "freitagbr@gmail.com"
- },
- {
- "name": "nfischer",
- "email": "ntfschr@gmail.com"
}
],
"name": "shelljs",
@@ -125,20 +80,10 @@
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
- "url": "git://github.com/shelljs/shelljs.git"
+ "url": "git://github.com/arturadib/shelljs.git"
},
"scripts": {
- "after-travis": "travis-check-changes",
- "changelog": "shelljs-changelog",
- "codecov": "codecov",
- "gendocs": "node scripts/generate-docs",
- "lint": "eslint .",
- "posttest": "npm run lint",
- "release:major": "shelljs-release major",
- "release:minor": "shelljs-release minor",
- "release:patch": "shelljs-release patch",
- "test": "nyc --reporter=text --reporter=lcov ava --serial test/*.js",
- "test-no-coverage": "ava --serial test/*.js"
+ "test": "node scripts/run-tests"
},
- "version": "0.7.7"
+ "version": "0.5.3"
}
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/shell.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/shell.js b/node_modules/shelljs/shell.js
index f155f3d..bdeb559 100644
--- a/node_modules/shelljs/shell.js
+++ b/node_modules/shelljs/shell.js
@@ -3,59 +3,126 @@
// Unix shell commands on top of Node's API
//
// Copyright (c) 2012 Artur Adib
-// http://github.com/shelljs/shelljs
+// http://github.com/arturadib/shelljs
//
var common = require('./src/common');
+
//@
//@ All commands run synchronously, unless otherwise stated.
-//@ All commands accept standard bash globbing characters (`*`, `?`, etc.),
-//@ compatible with the [node glob module](https://github.com/isaacs/node-glob).
-//@
-//@ For less-commonly used commands and features, please check out our [wiki
-//@ page](https://github.com/shelljs/shelljs/wiki).
//@
-// Include the docs for all the default commands
-//@commands
+//@include ./src/cd
+var _cd = require('./src/cd');
+exports.cd = common.wrap('cd', _cd);
+
+//@include ./src/pwd
+var _pwd = require('./src/pwd');
+exports.pwd = common.wrap('pwd', _pwd);
+
+//@include ./src/ls
+var _ls = require('./src/ls');
+exports.ls = common.wrap('ls', _ls);
+
+//@include ./src/find
+var _find = require('./src/find');
+exports.find = common.wrap('find', _find);
+
+//@include ./src/cp
+var _cp = require('./src/cp');
+exports.cp = common.wrap('cp', _cp);
+
+//@include ./src/rm
+var _rm = require('./src/rm');
+exports.rm = common.wrap('rm', _rm);
+
+//@include ./src/mv
+var _mv = require('./src/mv');
+exports.mv = common.wrap('mv', _mv);
+
+//@include ./src/mkdir
+var _mkdir = require('./src/mkdir');
+exports.mkdir = common.wrap('mkdir', _mkdir);
+
+//@include ./src/test
+var _test = require('./src/test');
+exports.test = common.wrap('test', _test);
+
+//@include ./src/cat
+var _cat = require('./src/cat');
+exports.cat = common.wrap('cat', _cat);
+
+//@include ./src/to
+var _to = require('./src/to');
+String.prototype.to = common.wrap('to', _to);
+
+//@include ./src/toEnd
+var _toEnd = require('./src/toEnd');
+String.prototype.toEnd = common.wrap('toEnd', _toEnd);
+
+//@include ./src/sed
+var _sed = require('./src/sed');
+exports.sed = common.wrap('sed', _sed);
+
+//@include ./src/grep
+var _grep = require('./src/grep');
+exports.grep = common.wrap('grep', _grep);
+
+//@include ./src/which
+var _which = require('./src/which');
+exports.which = common.wrap('which', _which);
+
+//@include ./src/echo
+var _echo = require('./src/echo');
+exports.echo = _echo; // don't common.wrap() as it could parse '-options'
+
+//@include ./src/dirs
+var _dirs = require('./src/dirs').dirs;
+exports.dirs = common.wrap("dirs", _dirs);
+var _pushd = require('./src/dirs').pushd;
+exports.pushd = common.wrap('pushd', _pushd);
+var _popd = require('./src/dirs').popd;
+exports.popd = common.wrap("popd", _popd);
-// Load all default commands
-require('./commands').forEach(function (command) {
- require('./src/' + command);
-});
+//@include ./src/ln
+var _ln = require('./src/ln');
+exports.ln = common.wrap('ln', _ln);
//@
//@ ### exit(code)
//@ Exits the current process with the given exit code.
exports.exit = process.exit;
-//@include ./src/error
-exports.error = require('./src/error');
-
-//@include ./src/common
-exports.ShellString = common.ShellString;
-
//@
//@ ### env['VAR_NAME']
-//@ Object containing environment variables (both getter and setter). Shortcut
-//@ to process.env.
+//@ Object containing environment variables (both getter and setter). Shortcut to process.env.
exports.env = process.env;
+//@include ./src/exec
+var _exec = require('./src/exec');
+exports.exec = common.wrap('exec', _exec, {notUnix:true});
+
+//@include ./src/chmod
+var _chmod = require('./src/chmod');
+exports.chmod = common.wrap('chmod', _chmod);
+
+
+
//@
-//@ ### Pipes
-//@
-//@ Examples:
+//@ ## Non-Unix commands
//@
-//@ ```javascript
-//@ grep('foo', 'file1.txt', 'file2.txt').sed(/o/g, 'a').to('output.txt');
-//@ echo('files with o\'s in the name:\n' + ls().grep('o'));
-//@ cat('test.js').exec('node'); // pipe to exec() call
-//@ ```
-//@
-//@ Commands can send their output to another command in a pipe-like fashion.
-//@ `sed`, `grep`, `cat`, `exec`, `to`, and `toEnd` can appear on the right-hand
-//@ side of a pipe. Pipes can be chained.
+
+//@include ./src/tempdir
+var _tempDir = require('./src/tempdir');
+exports.tempdir = common.wrap('tempdir', _tempDir);
+
+
+//@include ./src/error
+var _error = require('./src/error');
+exports.error = _error;
+
+
//@
//@ ## Configuration
@@ -65,7 +132,6 @@ exports.config = common.config;
//@
//@ ### config.silent
-//@
//@ Example:
//@
//@ ```javascript
@@ -81,72 +147,13 @@ exports.config = common.config;
//@
//@ ### config.fatal
-//@
//@ Example:
//@
//@ ```javascript
//@ require('shelljs/global');
-//@ config.fatal = true; // or set('-e');
-//@ cp('this_file_does_not_exist', '/dev/null'); // throws Error here
+//@ config.fatal = true;
+//@ cp('this_file_does_not_exist', '/dev/null'); // dies here
//@ /* more commands... */
//@ ```
//@
-//@ If `true` the script will throw a Javascript error when any shell.js
-//@ command encounters an error. Default is `false`. This is analogous to
-//@ Bash's `set -e`
-
-//@
-//@ ### config.verbose
-//@
-//@ Example:
-//@
-//@ ```javascript
-//@ config.verbose = true; // or set('-v');
-//@ cd('dir/');
-//@ ls('subdir/');
-//@ ```
-//@
-//@ Will print each command as follows:
-//@
-//@ ```
-//@ cd dir/
-//@ ls subdir/
-//@ ```
-
-//@
-//@ ### config.globOptions
-//@
-//@ Example:
-//@
-//@ ```javascript
-//@ config.globOptions = {nodir: true};
-//@ ```
-//@
-//@ Use this value for calls to `glob.sync()` instead of the default options.
-
-//@
-//@ ### config.reset()
-//@
-//@ Example:
-//@
-//@ ```javascript
-//@ var shell = require('shelljs');
-//@ // Make changes to shell.config, and do stuff...
-//@ /* ... */
-//@ shell.config.reset(); // reset to original state
-//@ // Do more stuff, but with original settings
-//@ /* ... */
-//@ ```
-//@
-//@ Reset shell.config to the defaults:
-//@
-//@ ```javascript
-//@ {
-//@ fatal: false,
-//@ globOptions: {},
-//@ maxdepth: 255,
-//@ noglob: false,
-//@ silent: false,
-//@ verbose: false,
-//@ }
-//@ ```
+//@ If `true` the script will die on errors. Default is `false`.
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/cat.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/cat.js b/node_modules/shelljs/src/cat.js
index a74a25c..f6f4d25 100644
--- a/node_modules/shelljs/src/cat.js
+++ b/node_modules/shelljs/src/cat.js
@@ -1,10 +1,6 @@
var common = require('./common');
var fs = require('fs');
-common.register('cat', _cat, {
- canReceivePipe: true,
-});
-
//@
//@ ### cat(file [, file ...])
//@ ### cat(file_array)
@@ -19,22 +15,29 @@ common.register('cat', _cat, {
//@
//@ Returns a string containing the given file, or a concatenated string
//@ containing the files if more than one file is given (a new line character is
-//@ introduced between each file).
+//@ introduced between each file). Wildcard `*` accepted.
function _cat(options, files) {
- var cat = common.readFromPipe();
+ var cat = '';
+
+ if (!files)
+ common.error('no paths given');
- if (!files && !cat) common.error('no paths given');
+ if (typeof files === 'string')
+ files = [].slice.call(arguments, 1);
+ // if it's array leave it as it is
- files = [].slice.call(arguments, 1);
+ files = common.expand(files);
- files.forEach(function (file) {
- if (!fs.existsSync(file)) {
+ files.forEach(function(file) {
+ if (!fs.existsSync(file))
common.error('no such file or directory: ' + file);
- }
- cat += fs.readFileSync(file, 'utf8');
+ cat += fs.readFileSync(file, 'utf8') + '\n';
});
- return cat;
+ if (cat[cat.length-1] === '\n')
+ cat = cat.substring(0, cat.length-1);
+
+ return common.ShellString(cat);
}
module.exports = _cat;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/cd.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/cd.js b/node_modules/shelljs/src/cd.js
index 634ed83..230f432 100644
--- a/node_modules/shelljs/src/cd.js
+++ b/node_modules/shelljs/src/cd.js
@@ -1,38 +1,19 @@
var fs = require('fs');
var common = require('./common');
-common.register('cd', _cd, {});
-
//@
-//@ ### cd([dir])
-//@ Changes to directory `dir` for the duration of the script. Changes to home
-//@ directory if no argument is supplied.
+//@ ### cd('dir')
+//@ Changes to directory `dir` for the duration of the script
function _cd(options, dir) {
- if (!dir) dir = common.getUserHome();
+ if (!dir)
+ common.error('directory not specified');
+
+ if (!fs.existsSync(dir))
+ common.error('no such file or directory: ' + dir);
- if (dir === '-') {
- if (!process.env.OLDPWD) {
- common.error('could not find previous directory');
- } else {
- dir = process.env.OLDPWD;
- }
- }
+ if (!fs.statSync(dir).isDirectory())
+ common.error('not a directory: ' + dir);
- try {
- var curDir = process.cwd();
- process.chdir(dir);
- process.env.OLDPWD = curDir;
- } catch (e) {
- // something went wrong, let's figure out the error
- var err;
- try {
- fs.statSync(dir); // if this succeeds, it must be some sort of file
- err = 'not a directory: ' + dir;
- } catch (e2) {
- err = 'no such file or directory: ' + dir;
- }
- if (err) common.error(err);
- }
- return '';
+ process.chdir(dir);
}
module.exports = _cd;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/chmod.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/chmod.js b/node_modules/shelljs/src/chmod.js
index ce5659e..f288893 100644
--- a/node_modules/shelljs/src/chmod.js
+++ b/node_modules/shelljs/src/chmod.js
@@ -4,37 +4,35 @@ var path = require('path');
var PERMS = (function (base) {
return {
- OTHER_EXEC: base.EXEC,
- OTHER_WRITE: base.WRITE,
- OTHER_READ: base.READ,
+ OTHER_EXEC : base.EXEC,
+ OTHER_WRITE : base.WRITE,
+ OTHER_READ : base.READ,
- GROUP_EXEC: base.EXEC << 3,
- GROUP_WRITE: base.WRITE << 3,
- GROUP_READ: base.READ << 3,
+ GROUP_EXEC : base.EXEC << 3,
+ GROUP_WRITE : base.WRITE << 3,
+ GROUP_READ : base.READ << 3,
- OWNER_EXEC: base.EXEC << 6,
- OWNER_WRITE: base.WRITE << 6,
- OWNER_READ: base.READ << 6,
+ OWNER_EXEC : base.EXEC << 6,
+ OWNER_WRITE : base.WRITE << 6,
+ OWNER_READ : base.READ << 6,
- // Literal octal numbers are apparently not allowed in "strict" javascript.
- STICKY: parseInt('01000', 8),
- SETGID: parseInt('02000', 8),
- SETUID: parseInt('04000', 8),
+ // Literal octal numbers are apparently not allowed in "strict" javascript. Using parseInt is
+ // the preferred way, else a jshint warning is thrown.
+ STICKY : parseInt('01000', 8),
+ SETGID : parseInt('02000', 8),
+ SETUID : parseInt('04000', 8),
- TYPE_MASK: parseInt('0770000', 8),
+ TYPE_MASK : parseInt('0770000', 8)
};
-}({
- EXEC: 1,
- WRITE: 2,
- READ: 4,
-}));
-
-common.register('chmod', _chmod, {
+})({
+ EXEC : 1,
+ WRITE : 2,
+ READ : 4
});
//@
-//@ ### chmod([options,] octal_mode || octal_string, file)
-//@ ### chmod([options,] symbolic_mode, file)
+//@ ### chmod(octal_mode || octal_string, file)
+//@ ### chmod(symbolic_mode, file)
//@
//@ Available options:
//@
@@ -48,7 +46,6 @@ common.register('chmod', _chmod, {
//@ chmod(755, '/Users/brandon');
//@ chmod('755', '/Users/brandon'); // same as above
//@ chmod('u+x', '/Users/brandon');
-//@ chmod('-R', 'a-w', '/Users/brandon');
//@ ```
//@
//@ Alters the permissions of a file or directory by either specifying the
@@ -65,8 +62,11 @@ function _chmod(options, mode, filePattern) {
// Special case where the specified file permissions started with - to subtract perms, which
// get picked up by the option parser as command flags.
// If we are down by one argument and options starts with -, shift everything over.
- [].unshift.call(arguments, '');
- } else {
+ filePattern = mode;
+ mode = options;
+ options = '';
+ }
+ else {
common.error('You must specify a file.');
}
}
@@ -74,17 +74,18 @@ function _chmod(options, mode, filePattern) {
options = common.parseOptions(options, {
'R': 'recursive',
'c': 'changes',
- 'v': 'verbose',
+ 'v': 'verbose'
});
- filePattern = [].slice.call(arguments, 2);
+ if (typeof filePattern === 'string') {
+ filePattern = [ filePattern ];
+ }
var files;
- // TODO: replace this with a call to common.expand()
if (options.recursive) {
files = [];
- filePattern.forEach(function addFile(expandedFile) {
+ common.expand(filePattern).forEach(function addFile(expandedFile) {
var stat = fs.lstatSync(expandedFile);
if (!stat.isSymbolicLink()) {
@@ -97,8 +98,9 @@ function _chmod(options, mode, filePattern) {
}
}
});
- } else {
- files = filePattern;
+ }
+ else {
+ files = common.expand(filePattern);
}
files.forEach(function innerChmod(file) {
@@ -112,9 +114,7 @@ function _chmod(options, mode, filePattern) {
return;
}
- var stat = fs.statSync(file);
- var isDir = stat.isDirectory();
- var perms = stat.mode;
+ var perms = fs.statSync(file).mode;
var type = perms & PERMS.TYPE_MASK;
var newPerms = perms;
@@ -122,6 +122,7 @@ function _chmod(options, mode, filePattern) {
if (isNaN(parseInt(mode, 8))) {
// parse options
mode.split(',').forEach(function (symbolicMode) {
+ /*jshint regexdash:true */
var pattern = /([ugoa]*)([=\+-])([rwxXst]*)/i;
var matches = pattern.exec(symbolicMode);
@@ -130,20 +131,15 @@ function _chmod(options, mode, filePattern) {
var operator = matches[2];
var change = matches[3];
- var changeOwner = applyTo.indexOf('u') !== -1 || applyTo === 'a' || applyTo === '';
- var changeGroup = applyTo.indexOf('g') !== -1 || applyTo === 'a' || applyTo === '';
- var changeOther = applyTo.indexOf('o') !== -1 || applyTo === 'a' || applyTo === '';
+ var changeOwner = applyTo.indexOf('u') != -1 || applyTo === 'a' || applyTo === '';
+ var changeGroup = applyTo.indexOf('g') != -1 || applyTo === 'a' || applyTo === '';
+ var changeOther = applyTo.indexOf('o') != -1 || applyTo === 'a' || applyTo === '';
- var changeRead = change.indexOf('r') !== -1;
- var changeWrite = change.indexOf('w') !== -1;
- var changeExec = change.indexOf('x') !== -1;
- var changeExecDir = change.indexOf('X') !== -1;
- var changeSticky = change.indexOf('t') !== -1;
- var changeSetuid = change.indexOf('s') !== -1;
-
- if (changeExecDir && isDir) {
- changeExec = true;
- }
+ var changeRead = change.indexOf('r') != -1;
+ var changeWrite = change.indexOf('w') != -1;
+ var changeExec = change.indexOf('x') != -1;
+ var changeSticky = change.indexOf('t') != -1;
+ var changeSetuid = change.indexOf('s') != -1;
var mask = 0;
if (changeOwner) {
@@ -173,37 +169,34 @@ function _chmod(options, mode, filePattern) {
case '=':
newPerms = type + mask;
- // According to POSIX, when using = to explicitly set the
- // permissions, setuid and setgid can never be cleared.
+ // According to POSIX, when using = to explicitly set the permissions, setuid and setgid can never be cleared.
if (fs.statSync(file).isDirectory()) {
newPerms |= (PERMS.SETUID + PERMS.SETGID) & perms;
}
break;
- default:
- common.error('Could not recognize operator: `' + operator + '`');
}
if (options.verbose) {
- console.log(file + ' -> ' + newPerms.toString(8));
+ log(file + ' -> ' + newPerms.toString(8));
}
- if (perms !== newPerms) {
+ if (perms != newPerms) {
if (!options.verbose && options.changes) {
- console.log(file + ' -> ' + newPerms.toString(8));
+ log(file + ' -> ' + newPerms.toString(8));
}
fs.chmodSync(file, newPerms);
- perms = newPerms; // for the next round of changes!
}
- } else {
+ }
+ else {
common.error('Invalid symbolic mode change: ' + symbolicMode);
}
});
- } else {
+ }
+ else {
// they gave us a full number
newPerms = type + parseInt(mode, 8);
- // POSIX rules are that setuid and setgid can only be added using numeric
- // form, but not cleared.
+ // POSIX rules are that setuid and setgid can only be added using numeric form, but not cleared.
if (fs.statSync(file).isDirectory()) {
newPerms |= (PERMS.SETUID + PERMS.SETGID) & perms;
}
@@ -211,6 +204,5 @@ function _chmod(options, mode, filePattern) {
fs.chmodSync(file, newPerms);
}
});
- return '';
}
module.exports = _chmod;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/common.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/common.js b/node_modules/shelljs/src/common.js
index f5197d8..d8c2312 100644
--- a/node_modules/shelljs/src/common.js
+++ b/node_modules/shelljs/src/common.js
@@ -1,247 +1,86 @@
-// Ignore warning about 'new String()'
-/* eslint no-new-wrappers: 0 */
-'use strict';
-
var os = require('os');
var fs = require('fs');
-var glob = require('glob');
-var shell = require('..');
-
-var shellMethods = Object.create(shell);
-
-// objectAssign(target_obj, source_obj1 [, source_obj2 ...])
-// "Ponyfill" for Object.assign
-// objectAssign({A:1}, {b:2}, {c:3}) returns {A:1, b:2, c:3}
-var objectAssign = typeof Object.assign === 'function' ?
- Object.assign :
- function objectAssign(target) {
- var sources = [].slice.call(arguments, 1);
- sources.forEach(function (source) {
- Object.keys(source).forEach(function (key) {
- target[key] = source[key];
- });
- });
-
- return target;
- };
-exports.extend = objectAssign;
-
-// Check if we're running under electron
-var isElectron = Boolean(process.versions.electron);
-
-// Module globals (assume no execPath by default)
-var DEFAULT_CONFIG = {
- fatal: false,
- globOptions: {},
- maxdepth: 255,
- noglob: false,
- silent: false,
- verbose: false,
- execPath: null,
-};
+var _ls = require('./ls');
+// Module globals
var config = {
- reset: function () {
- objectAssign(this, DEFAULT_CONFIG);
- if (!isElectron) {
- this.execPath = process.execPath;
- }
- },
- resetForTesting: function () {
- this.reset();
- this.silent = true;
- },
+ silent: false,
+ fatal: false
};
-
-config.reset();
exports.config = config;
var state = {
error: null,
- errorCode: 0,
currentCmd: 'shell.js',
- tempDir: null,
+ tempDir: null
};
exports.state = state;
-delete process.env.OLDPWD; // initially, there's no previous directory
-
var platform = os.type().match(/^Win/) ? 'win' : 'unix';
exports.platform = platform;
-// This is populated by calls to commonl.wrap()
-var pipeMethods = [];
-
-// Reliably test if something is any sort of javascript object
-function isObject(a) {
- return typeof a === 'object' && a !== null;
-}
-exports.isObject = isObject;
-
function log() {
- /* istanbul ignore next */
- if (!config.silent) {
- console.error.apply(console, arguments);
- }
+ if (!config.silent)
+ console.log.apply(this, arguments);
}
exports.log = log;
-// Converts strings to be equivalent across all platforms. Primarily responsible
-// for making sure we use '/' instead of '\' as path separators, but this may be
-// expanded in the future if necessary
-function convertErrorOutput(msg) {
- if (typeof msg !== 'string') {
- throw new TypeError('input must be a string');
- }
- return msg.replace(/\\/g, '/');
-}
-exports.convertErrorOutput = convertErrorOutput;
-
-// Shows error message. Throws if config.fatal is true
-function error(msg, _code, options) {
- // Validate input
- if (typeof msg !== 'string') throw new Error('msg must be a string');
-
- var DEFAULT_OPTIONS = {
- continue: false,
- code: 1,
- prefix: state.currentCmd + ': ',
- silent: false,
- };
-
- if (typeof _code === 'number' && isObject(options)) {
- options.code = _code;
- } else if (isObject(_code)) { // no 'code'
- options = _code;
- } else if (typeof _code === 'number') { // no 'options'
- options = { code: _code };
- } else if (typeof _code !== 'number') { // only 'msg'
- options = {};
- }
- options = objectAssign({}, DEFAULT_OPTIONS, options);
-
- if (!state.errorCode) state.errorCode = options.code;
+// Shows error message. Throws unless _continue or config.fatal are true
+function error(msg, _continue) {
+ if (state.error === null)
+ state.error = '';
+ state.error += state.currentCmd + ': ' + msg + '\n';
- var logEntry = convertErrorOutput(options.prefix + msg);
- state.error = state.error ? state.error + '\n' : '';
- state.error += logEntry;
+ if (msg.length > 0)
+ log(state.error);
- // Throw an error, or log the entry
- if (config.fatal) throw new Error(logEntry);
- if (msg.length > 0 && !options.silent) log(logEntry);
+ if (config.fatal)
+ process.exit(1);
- if (!options.continue) {
- throw {
- msg: 'earlyExit',
- retValue: (new ShellString('', state.error, state.errorCode)),
- };
- }
+ if (!_continue)
+ throw '';
}
exports.error = error;
-//@
-//@ ### ShellString(str)
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ var foo = ShellString('hello world');
-//@ ```
-//@
-//@ Turns a regular string into a string-like object similar to what each
-//@ command returns. This has special methods, like `.to()` and `.toEnd()`
-function ShellString(stdout, stderr, code) {
- var that;
- if (stdout instanceof Array) {
- that = stdout;
- that.stdout = stdout.join('\n');
- if (stdout.length > 0) that.stdout += '\n';
- } else {
- that = new String(stdout);
- that.stdout = stdout;
- }
- that.stderr = stderr;
- that.code = code;
- // A list of all commands that can appear on the right-hand side of a pipe
- // (populated by calls to common.wrap())
- pipeMethods.forEach(function (cmd) {
- that[cmd] = shellMethods[cmd].bind(that);
- });
- return that;
+// In the future, when Proxies are default, we can add methods like `.to()` to primitive strings.
+// For now, this is a dummy function to bookmark places we need such strings
+function ShellString(str) {
+ return str;
}
-
exports.ShellString = ShellString;
-// Return the home directory in a platform-agnostic way, with consideration for
-// older versions of node
-function getUserHome() {
- var result;
- if (os.homedir) {
- result = os.homedir(); // node 3+
- } else {
- result = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'];
- }
- return result;
-}
-exports.getUserHome = getUserHome;
-
-// Returns {'alice': true, 'bob': false} when passed a string and dictionary as follows:
+// Returns {'alice': true, 'bob': false} when passed a dictionary, e.g.:
// parseOptions('-a', {'a':'alice', 'b':'bob'});
-// Returns {'reference': 'string-value', 'bob': false} when passed two dictionaries of the form:
-// parseOptions({'-r': 'string-value'}, {'r':'reference', 'b':'bob'});
-function parseOptions(opt, map, errorOptions) {
- // Validate input
- if (typeof opt !== 'string' && !isObject(opt)) {
- throw new Error('options must be strings or key-value pairs');
- } else if (!isObject(map)) {
- throw new Error('parseOptions() internal error: map must be an object');
- } else if (errorOptions && !isObject(errorOptions)) {
- throw new Error('parseOptions() internal error: errorOptions must be object');
- }
+function parseOptions(str, map) {
+ if (!map)
+ error('parseOptions() internal error: no map given');
// All options are false by default
var options = {};
- Object.keys(map).forEach(function (letter) {
- var optName = map[letter];
- if (optName[0] !== '!') {
- options[optName] = false;
- }
- });
+ for (var letter in map)
+ options[map[letter]] = false;
- if (opt === '') return options; // defaults
+ if (!str)
+ return options; // defaults
- if (typeof opt === 'string') {
- if (opt[0] !== '-') {
- error("Options string must start with a '-'", errorOptions || {});
- }
+ if (typeof str !== 'string')
+ error('parseOptions() internal error: wrong str');
- // e.g. chars = ['R', 'f']
- var chars = opt.slice(1).split('');
+ // e.g. match[1] = 'Rf' for str = '-Rf'
+ var match = str.match(/^\-(.+)/);
+ if (!match)
+ return options;
+
+ // e.g. chars = ['R', 'f']
+ var chars = match[1].split('');
+
+ chars.forEach(function(c) {
+ if (c in map)
+ options[map[c]] = true;
+ else
+ error('option not recognized: '+c);
+ });
- chars.forEach(function (c) {
- if (c in map) {
- var optionName = map[c];
- if (optionName[0] === '!') {
- options[optionName.slice(1)] = false;
- } else {
- options[optionName] = true;
- }
- } else {
- error('option not recognized: ' + c, errorOptions || {});
- }
- });
- } else { // opt is an Object
- Object.keys(opt).forEach(function (key) {
- // key is a string of the form '-r', '-d', etc.
- var c = key[1];
- if (c in map) {
- var optionName = map[c];
- options[optionName] = opt[key]; // assign the given value
- } else {
- error('option not recognized: ' + c, errorOptions || {});
- }
- });
- }
return options;
}
exports.parseOptions = parseOptions;
@@ -251,18 +90,29 @@ exports.parseOptions = parseOptions;
// expand(['file*.js']) = ['file1.js', 'file2.js', ...]
// (if the files 'file1.js', 'file2.js', etc, exist in the current dir)
function expand(list) {
- if (!Array.isArray(list)) {
- throw new TypeError('must be an array');
- }
var expanded = [];
- list.forEach(function (listEl) {
- // Don't expand non-strings
- if (typeof listEl !== 'string') {
- expanded.push(listEl);
+ list.forEach(function(listEl) {
+ // Wildcard present on directory names ?
+ if(listEl.search(/\*[^\/]*\//) > -1 || listEl.search(/\*\*[^\/]*\//) > -1) {
+ var match = listEl.match(/^([^*]+\/|)(.*)/);
+ var root = match[1];
+ var rest = match[2];
+ var restRegex = rest.replace(/\*\*/g, ".*").replace(/\*/g, "[^\\/]*");
+ restRegex = new RegExp(restRegex);
+
+ _ls('-R', root).filter(function (e) {
+ return restRegex.test(e);
+ }).forEach(function(file) {
+ expanded.push(file);
+ });
+ }
+ // Wildcard present on file names ?
+ else if (listEl.search(/\*/) > -1) {
+ _ls('', listEl).forEach(function(file) {
+ expanded.push(file);
+ });
} else {
- var ret = glob.sync(listEl, config.globOptions);
- // if glob fails, interpret the string literally
- expanded = expanded.concat(ret.length > 0 ? ret : [listEl]);
+ expanded.push(listEl);
}
});
return expanded;
@@ -274,9 +124,8 @@ exports.expand = expand;
function unlinkSync(file) {
try {
fs.unlinkSync(file);
- } catch (e) {
+ } catch(e) {
// Try to override file permission
- /* istanbul ignore next */
if (e.code === 'EPERM') {
fs.chmodSync(file, '0666');
fs.unlinkSync(file);
@@ -290,120 +139,61 @@ exports.unlinkSync = unlinkSync;
// e.g. 'shelljs_a5f185d0443ca...'
function randomFileName() {
function randomHash(count) {
- if (count === 1) {
- return parseInt(16 * Math.random(), 10).toString(16);
- }
- var hash = '';
- for (var i = 0; i < count; i++) {
- hash += randomHash(1);
+ if (count === 1)
+ return parseInt(16*Math.random(), 10).toString(16);
+ else {
+ var hash = '';
+ for (var i=0; i<count; i++)
+ hash += randomHash(1);
+ return hash;
}
- return hash;
}
- return 'shelljs_' + randomHash(20);
+ return 'shelljs_'+randomHash(20);
}
exports.randomFileName = randomFileName;
-// Common wrapper for all Unix-like commands that performs glob expansion,
-// command-logging, and other nice things
+// extend(target_obj, source_obj1 [, source_obj2 ...])
+// Shallow extend, e.g.:
+// extend({A:1}, {b:2}, {c:3}) returns {A:1, b:2, c:3}
+function extend(target) {
+ var sources = [].slice.call(arguments, 1);
+ sources.forEach(function(source) {
+ for (var key in source)
+ target[key] = source[key];
+ });
+
+ return target;
+}
+exports.extend = extend;
+
+// Common wrapper for all Unix-like commands
function wrap(cmd, fn, options) {
- options = options || {};
- if (options.canReceivePipe) {
- pipeMethods.push(cmd);
- }
- return function () {
+ return function() {
var retValue = null;
state.currentCmd = cmd;
state.error = null;
- state.errorCode = 0;
try {
var args = [].slice.call(arguments, 0);
- // Log the command to stderr, if appropriate
- if (config.verbose) {
- console.error.apply(console, [cmd].concat(args));
- }
-
- // If this is coming from a pipe, let's set the pipedValue (otherwise, set
- // it to the empty string)
- state.pipedValue = (this && typeof this.stdout === 'string') ? this.stdout : '';
-
- if (options.unix === false) { // this branch is for exec()
+ if (options && options.notUnix) {
retValue = fn.apply(this, args);
- } else { // and this branch is for everything else
- if (isObject(args[0]) && args[0].constructor.name === 'Object') {
- // a no-op, allowing the syntax `touch({'-r': file}, ...)`
- } else if (args.length === 0 || typeof args[0] !== 'string' || args[0].length <= 1 || args[0][0] !== '-') {
+ } else {
+ if (args.length === 0 || typeof args[0] !== 'string' || args[0][0] !== '-')
args.unshift(''); // only add dummy option if '-option' not already present
- }
-
- // flatten out arrays that are arguments, to make the syntax:
- // `cp([file1, file2, file3], dest);`
- // equivalent to:
- // `cp(file1, file2, file3, dest);`
- args = args.reduce(function (accum, cur) {
- if (Array.isArray(cur)) {
- return accum.concat(cur);
- }
- accum.push(cur);
- return accum;
- }, []);
-
- // Convert ShellStrings (basically just String objects) to regular strings
- args = args.map(function (arg) {
- if (isObject(arg) && arg.constructor.name === 'String') {
- return arg.toString();
- }
- return arg;
- });
-
- // Expand the '~' if appropriate
- var homeDir = getUserHome();
- args = args.map(function (arg) {
- if (typeof arg === 'string' && arg.slice(0, 2) === '~/' || arg === '~') {
- return arg.replace(/^~/, homeDir);
- }
- return arg;
- });
-
- // Perform glob-expansion on all arguments after globStart, but preserve
- // the arguments before it (like regexes for sed and grep)
- if (!config.noglob && options.allowGlobbing === true) {
- args = args.slice(0, options.globStart).concat(expand(args.slice(options.globStart)));
- }
-
- try {
- // parse options if options are provided
- if (isObject(options.cmdOptions)) {
- args[0] = parseOptions(args[0], options.cmdOptions);
- }
-
- retValue = fn.apply(this, args);
- } catch (e) {
- /* istanbul ignore else */
- if (e.msg === 'earlyExit') {
- retValue = e.retValue;
- } else {
- throw e; // this is probably a bug that should be thrown up the call stack
- }
- }
+ retValue = fn.apply(this, args);
}
} catch (e) {
- /* istanbul ignore next */
if (!state.error) {
// If state.error hasn't been set it's an error thrown by Node, not us - probably a bug...
- console.error('ShellJS: internal error');
- console.error(e.stack || e);
+ console.log('shell.js: internal error');
+ console.log(e.stack || e);
process.exit(1);
}
- if (config.fatal) throw e;
- }
-
- if (options.wrapOutput &&
- (typeof retValue === 'string' || Array.isArray(retValue))) {
- retValue = new ShellString(retValue, state.error, state.errorCode);
+ if (config.fatal)
+ throw e;
}
state.currentCmd = 'shell.js';
@@ -411,40 +201,3 @@ function wrap(cmd, fn, options) {
};
} // wrap
exports.wrap = wrap;
-
-// This returns all the input that is piped into the current command (or the
-// empty string, if this isn't on the right-hand side of a pipe
-function _readFromPipe() {
- return state.pipedValue;
-}
-exports.readFromPipe = _readFromPipe;
-
-var DEFAULT_WRAP_OPTIONS = {
- allowGlobbing: true,
- canReceivePipe: false,
- cmdOptions: false,
- globStart: 1,
- pipeOnly: false,
- unix: true,
- wrapOutput: true,
- overWrite: false,
-};
-
-// Register a new ShellJS command
-function _register(name, implementation, wrapOptions) {
- wrapOptions = wrapOptions || {};
- // If an option isn't specified, use the default
- wrapOptions = objectAssign({}, DEFAULT_WRAP_OPTIONS, wrapOptions);
-
- if (shell[name] && !wrapOptions.overWrite) {
- throw new Error('unable to overwrite `' + name + '` command');
- }
-
- if (wrapOptions.pipeOnly) {
- wrapOptions.canReceivePipe = true;
- shellMethods[name] = wrap(name, implementation, wrapOptions);
- } else {
- shell[name] = wrap(name, implementation, wrapOptions);
- }
-}
-exports.register = _register;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[08/25] cordova-browser git commit: cleaned up console.logs
Posted by pu...@apache.org.
cleaned up console.logs
Project: http://git-wip-us.apache.org/repos/asf/cordova-browser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-browser/commit/4a07e78c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-browser/tree/4a07e78c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-browser/diff/4a07e78c
Branch: refs/heads/master
Commit: 4a07e78c60e538dad6e2132d49324497f133c944
Parents: 7d48b14
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu Apr 13 18:02:20 2017 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu Apr 13 18:02:20 2017 -0700
----------------------------------------------------------------------
bin/template/cordova/Api.js | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/4a07e78c/bin/template/cordova/Api.js
----------------------------------------------------------------------
diff --git a/bin/template/cordova/Api.js b/bin/template/cordova/Api.js
index 4a75745..720ccdf 100644
--- a/bin/template/cordova/Api.js
+++ b/bin/template/cordova/Api.js
@@ -89,9 +89,8 @@ Api.updatePlatform = function (dest, options, events) {
};
Api.prototype.getPlatformInfo = function () {
- console.log("browser-platform:Api:getPlatformInfo");
+ // console.log("browser-platform:Api:getPlatformInfo");
// return PlatformInfo object
-
return {
"locations":this.locations,
"root": this.root,
@@ -102,22 +101,21 @@ Api.prototype.getPlatformInfo = function () {
};
Api.prototype.prepare = function (cordovaProject) {
- console.log("browser-platform:Api:prepare");
+ //console.log("browser-platform:Api:prepare");
return Promise.resolve();
};
Api.prototype.addPlugin = function (plugin, installOptions) {
- console.log("browser-platform:Api:addPlugin");
+ //console.log("browser-platform:Api:addPlugin");
return Promise.resolve();
};
Api.prototype.removePlugin = function (plugin, uninstallOptions) {
- console.log("browser-platform:Api:removePlugin");
+ //console.log("browser-platform:Api:removePlugin");
return Promise.resolve();
};
Api.prototype.build = function (buildOptions) {
- console.log("API building this shit");
var self = this;
return require('./lib/check_reqs').run()
.then(function () {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[20/25] cordova-browser git commit: ignore vscode
Posted by pu...@apache.org.
ignore vscode
Project: http://git-wip-us.apache.org/repos/asf/cordova-browser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-browser/commit/d5fcd3f0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-browser/tree/d5fcd3f0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-browser/diff/d5fcd3f0
Branch: refs/heads/master
Commit: d5fcd3f0b0307ca4f5c571dd0ec11022fe0b4c94
Parents: 098fc65
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Fri May 5 16:47:21 2017 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Fri May 5 16:47:21 2017 -0700
----------------------------------------------------------------------
.gitignore | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/d5fcd3f0/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index ec8aba6..1db634f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,10 +3,9 @@ temp
.DS_Store
.gitcore
*.jar
-
+.vscode
node_modules/
-
!node_modules/adm-zip
!node_modules/cordova-serve
!node_modules/nopt
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[12/25] cordova-browser git commit: update shelljs version,
prepare is working
Posted by pu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/chmod.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/chmod.js b/node_modules/shelljs/src/chmod.js
index 6c6de10..ce5659e 100644
--- a/node_modules/shelljs/src/chmod.js
+++ b/node_modules/shelljs/src/chmod.js
@@ -4,35 +4,37 @@ var path = require('path');
var PERMS = (function (base) {
return {
- OTHER_EXEC : base.EXEC,
- OTHER_WRITE : base.WRITE,
- OTHER_READ : base.READ,
+ OTHER_EXEC: base.EXEC,
+ OTHER_WRITE: base.WRITE,
+ OTHER_READ: base.READ,
- GROUP_EXEC : base.EXEC << 3,
- GROUP_WRITE : base.WRITE << 3,
- GROUP_READ : base.READ << 3,
+ GROUP_EXEC: base.EXEC << 3,
+ GROUP_WRITE: base.WRITE << 3,
+ GROUP_READ: base.READ << 3,
- OWNER_EXEC : base.EXEC << 6,
- OWNER_WRITE : base.WRITE << 6,
- OWNER_READ : base.READ << 6,
+ OWNER_EXEC: base.EXEC << 6,
+ OWNER_WRITE: base.WRITE << 6,
+ OWNER_READ: base.READ << 6,
- // Literal octal numbers are apparently not allowed in "strict" javascript. Using parseInt is
- // the preferred way, else a jshint warning is thrown.
- STICKY : parseInt('01000', 8),
- SETGID : parseInt('02000', 8),
- SETUID : parseInt('04000', 8),
+ // Literal octal numbers are apparently not allowed in "strict" javascript.
+ STICKY: parseInt('01000', 8),
+ SETGID: parseInt('02000', 8),
+ SETUID: parseInt('04000', 8),
- TYPE_MASK : parseInt('0770000', 8)
+ TYPE_MASK: parseInt('0770000', 8),
};
-})({
- EXEC : 1,
- WRITE : 2,
- READ : 4
+}({
+ EXEC: 1,
+ WRITE: 2,
+ READ: 4,
+}));
+
+common.register('chmod', _chmod, {
});
//@
-//@ ### chmod(octal_mode || octal_string, file)
-//@ ### chmod(symbolic_mode, file)
+//@ ### chmod([options,] octal_mode || octal_string, file)
+//@ ### chmod([options,] symbolic_mode, file)
//@
//@ Available options:
//@
@@ -46,6 +48,7 @@ var PERMS = (function (base) {
//@ chmod(755, '/Users/brandon');
//@ chmod('755', '/Users/brandon'); // same as above
//@ chmod('u+x', '/Users/brandon');
+//@ chmod('-R', 'a-w', '/Users/brandon');
//@ ```
//@
//@ Alters the permissions of a file or directory by either specifying the
@@ -62,11 +65,8 @@ function _chmod(options, mode, filePattern) {
// Special case where the specified file permissions started with - to subtract perms, which
// get picked up by the option parser as command flags.
// If we are down by one argument and options starts with -, shift everything over.
- filePattern = mode;
- mode = options;
- options = '';
- }
- else {
+ [].unshift.call(arguments, '');
+ } else {
common.error('You must specify a file.');
}
}
@@ -74,18 +74,17 @@ function _chmod(options, mode, filePattern) {
options = common.parseOptions(options, {
'R': 'recursive',
'c': 'changes',
- 'v': 'verbose'
+ 'v': 'verbose',
});
- if (typeof filePattern === 'string') {
- filePattern = [ filePattern ];
- }
+ filePattern = [].slice.call(arguments, 2);
var files;
+ // TODO: replace this with a call to common.expand()
if (options.recursive) {
files = [];
- common.expand(filePattern).forEach(function addFile(expandedFile) {
+ filePattern.forEach(function addFile(expandedFile) {
var stat = fs.lstatSync(expandedFile);
if (!stat.isSymbolicLink()) {
@@ -98,9 +97,8 @@ function _chmod(options, mode, filePattern) {
}
}
});
- }
- else {
- files = common.expand(filePattern);
+ } else {
+ files = filePattern;
}
files.forEach(function innerChmod(file) {
@@ -124,7 +122,6 @@ function _chmod(options, mode, filePattern) {
if (isNaN(parseInt(mode, 8))) {
// parse options
mode.split(',').forEach(function (symbolicMode) {
- /*jshint regexdash:true */
var pattern = /([ugoa]*)([=\+-])([rwxXst]*)/i;
var matches = pattern.exec(symbolicMode);
@@ -133,19 +130,20 @@ function _chmod(options, mode, filePattern) {
var operator = matches[2];
var change = matches[3];
- var changeOwner = applyTo.indexOf('u') != -1 || applyTo === 'a' || applyTo === '';
- var changeGroup = applyTo.indexOf('g') != -1 || applyTo === 'a' || applyTo === '';
- var changeOther = applyTo.indexOf('o') != -1 || applyTo === 'a' || applyTo === '';
+ var changeOwner = applyTo.indexOf('u') !== -1 || applyTo === 'a' || applyTo === '';
+ var changeGroup = applyTo.indexOf('g') !== -1 || applyTo === 'a' || applyTo === '';
+ var changeOther = applyTo.indexOf('o') !== -1 || applyTo === 'a' || applyTo === '';
- var changeRead = change.indexOf('r') != -1;
- var changeWrite = change.indexOf('w') != -1;
- var changeExec = change.indexOf('x') != -1;
- var changeExecDir = change.indexOf('X') != -1;
- var changeSticky = change.indexOf('t') != -1;
- var changeSetuid = change.indexOf('s') != -1;
+ var changeRead = change.indexOf('r') !== -1;
+ var changeWrite = change.indexOf('w') !== -1;
+ var changeExec = change.indexOf('x') !== -1;
+ var changeExecDir = change.indexOf('X') !== -1;
+ var changeSticky = change.indexOf('t') !== -1;
+ var changeSetuid = change.indexOf('s') !== -1;
- if (changeExecDir && isDir)
+ if (changeExecDir && isDir) {
changeExec = true;
+ }
var mask = 0;
if (changeOwner) {
@@ -175,35 +173,37 @@ function _chmod(options, mode, filePattern) {
case '=':
newPerms = type + mask;
- // According to POSIX, when using = to explicitly set the permissions, setuid and setgid can never be cleared.
+ // According to POSIX, when using = to explicitly set the
+ // permissions, setuid and setgid can never be cleared.
if (fs.statSync(file).isDirectory()) {
newPerms |= (PERMS.SETUID + PERMS.SETGID) & perms;
}
break;
+ default:
+ common.error('Could not recognize operator: `' + operator + '`');
}
if (options.verbose) {
console.log(file + ' -> ' + newPerms.toString(8));
}
- if (perms != newPerms) {
+ if (perms !== newPerms) {
if (!options.verbose && options.changes) {
console.log(file + ' -> ' + newPerms.toString(8));
}
fs.chmodSync(file, newPerms);
perms = newPerms; // for the next round of changes!
}
- }
- else {
+ } else {
common.error('Invalid symbolic mode change: ' + symbolicMode);
}
});
- }
- else {
+ } else {
// they gave us a full number
newPerms = type + parseInt(mode, 8);
- // POSIX rules are that setuid and setgid can only be added using numeric form, but not cleared.
+ // POSIX rules are that setuid and setgid can only be added using numeric
+ // form, but not cleared.
if (fs.statSync(file).isDirectory()) {
newPerms |= (PERMS.SETUID + PERMS.SETGID) & perms;
}
@@ -211,5 +211,6 @@ function _chmod(options, mode, filePattern) {
fs.chmodSync(file, newPerms);
}
});
+ return '';
}
module.exports = _chmod;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/common.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/common.js b/node_modules/shelljs/src/common.js
index 33198bd..f5197d8 100644
--- a/node_modules/shelljs/src/common.js
+++ b/node_modules/shelljs/src/common.js
@@ -1,68 +1,186 @@
+// Ignore warning about 'new String()'
+/* eslint no-new-wrappers: 0 */
+'use strict';
+
var os = require('os');
var fs = require('fs');
-var _ls = require('./ls');
+var glob = require('glob');
+var shell = require('..');
-// Module globals
-var config = {
- silent: false,
+var shellMethods = Object.create(shell);
+
+// objectAssign(target_obj, source_obj1 [, source_obj2 ...])
+// "Ponyfill" for Object.assign
+// objectAssign({A:1}, {b:2}, {c:3}) returns {A:1, b:2, c:3}
+var objectAssign = typeof Object.assign === 'function' ?
+ Object.assign :
+ function objectAssign(target) {
+ var sources = [].slice.call(arguments, 1);
+ sources.forEach(function (source) {
+ Object.keys(source).forEach(function (key) {
+ target[key] = source[key];
+ });
+ });
+
+ return target;
+ };
+exports.extend = objectAssign;
+
+// Check if we're running under electron
+var isElectron = Boolean(process.versions.electron);
+
+// Module globals (assume no execPath by default)
+var DEFAULT_CONFIG = {
fatal: false,
+ globOptions: {},
+ maxdepth: 255,
+ noglob: false,
+ silent: false,
verbose: false,
+ execPath: null,
};
+
+var config = {
+ reset: function () {
+ objectAssign(this, DEFAULT_CONFIG);
+ if (!isElectron) {
+ this.execPath = process.execPath;
+ }
+ },
+ resetForTesting: function () {
+ this.reset();
+ this.silent = true;
+ },
+};
+
+config.reset();
exports.config = config;
var state = {
error: null,
+ errorCode: 0,
currentCmd: 'shell.js',
- previousDir: null,
- tempDir: null
+ tempDir: null,
};
exports.state = state;
+delete process.env.OLDPWD; // initially, there's no previous directory
+
var platform = os.type().match(/^Win/) ? 'win' : 'unix';
exports.platform = platform;
+// This is populated by calls to commonl.wrap()
+var pipeMethods = [];
+
+// Reliably test if something is any sort of javascript object
+function isObject(a) {
+ return typeof a === 'object' && a !== null;
+}
+exports.isObject = isObject;
+
function log() {
- if (!config.silent)
+ /* istanbul ignore next */
+ if (!config.silent) {
console.error.apply(console, arguments);
+ }
}
exports.log = log;
-// Shows error message. Throws unless _continue or config.fatal are true
-function error(msg, _continue) {
- if (state.error === null)
- state.error = '';
- var log_entry = state.currentCmd + ': ' + msg;
- if (state.error === '')
- state.error = log_entry;
- else
- state.error += '\n' + log_entry;
+// Converts strings to be equivalent across all platforms. Primarily responsible
+// for making sure we use '/' instead of '\' as path separators, but this may be
+// expanded in the future if necessary
+function convertErrorOutput(msg) {
+ if (typeof msg !== 'string') {
+ throw new TypeError('input must be a string');
+ }
+ return msg.replace(/\\/g, '/');
+}
+exports.convertErrorOutput = convertErrorOutput;
+
+// Shows error message. Throws if config.fatal is true
+function error(msg, _code, options) {
+ // Validate input
+ if (typeof msg !== 'string') throw new Error('msg must be a string');
+
+ var DEFAULT_OPTIONS = {
+ continue: false,
+ code: 1,
+ prefix: state.currentCmd + ': ',
+ silent: false,
+ };
- if (msg.length > 0)
- log(log_entry);
+ if (typeof _code === 'number' && isObject(options)) {
+ options.code = _code;
+ } else if (isObject(_code)) { // no 'code'
+ options = _code;
+ } else if (typeof _code === 'number') { // no 'options'
+ options = { code: _code };
+ } else if (typeof _code !== 'number') { // only 'msg'
+ options = {};
+ }
+ options = objectAssign({}, DEFAULT_OPTIONS, options);
+
+ if (!state.errorCode) state.errorCode = options.code;
+
+ var logEntry = convertErrorOutput(options.prefix + msg);
+ state.error = state.error ? state.error + '\n' : '';
+ state.error += logEntry;
- if (config.fatal)
- process.exit(1);
+ // Throw an error, or log the entry
+ if (config.fatal) throw new Error(logEntry);
+ if (msg.length > 0 && !options.silent) log(logEntry);
- if (!_continue)
- throw '';
+ if (!options.continue) {
+ throw {
+ msg: 'earlyExit',
+ retValue: (new ShellString('', state.error, state.errorCode)),
+ };
+ }
}
exports.error = error;
-// In the future, when Proxies are default, we can add methods like `.to()` to primitive strings.
-// For now, this is a dummy function to bookmark places we need such strings
-function ShellString(str) {
- return str;
+//@
+//@ ### ShellString(str)
+//@
+//@ Examples:
+//@
+//@ ```javascript
+//@ var foo = ShellString('hello world');
+//@ ```
+//@
+//@ Turns a regular string into a string-like object similar to what each
+//@ command returns. This has special methods, like `.to()` and `.toEnd()`
+function ShellString(stdout, stderr, code) {
+ var that;
+ if (stdout instanceof Array) {
+ that = stdout;
+ that.stdout = stdout.join('\n');
+ if (stdout.length > 0) that.stdout += '\n';
+ } else {
+ that = new String(stdout);
+ that.stdout = stdout;
+ }
+ that.stderr = stderr;
+ that.code = code;
+ // A list of all commands that can appear on the right-hand side of a pipe
+ // (populated by calls to common.wrap())
+ pipeMethods.forEach(function (cmd) {
+ that[cmd] = shellMethods[cmd].bind(that);
+ });
+ return that;
}
+
exports.ShellString = ShellString;
// Return the home directory in a platform-agnostic way, with consideration for
// older versions of node
function getUserHome() {
var result;
- if (os.homedir)
+ if (os.homedir) {
result = os.homedir(); // node 3+
- else
+ } else {
result = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'];
+ }
return result;
}
exports.getUserHome = getUserHome;
@@ -71,52 +189,58 @@ exports.getUserHome = getUserHome;
// parseOptions('-a', {'a':'alice', 'b':'bob'});
// Returns {'reference': 'string-value', 'bob': false} when passed two dictionaries of the form:
// parseOptions({'-r': 'string-value'}, {'r':'reference', 'b':'bob'});
-function parseOptions(opt, map) {
- if (!map)
- error('parseOptions() internal error: no map given');
+function parseOptions(opt, map, errorOptions) {
+ // Validate input
+ if (typeof opt !== 'string' && !isObject(opt)) {
+ throw new Error('options must be strings or key-value pairs');
+ } else if (!isObject(map)) {
+ throw new Error('parseOptions() internal error: map must be an object');
+ } else if (errorOptions && !isObject(errorOptions)) {
+ throw new Error('parseOptions() internal error: errorOptions must be object');
+ }
// All options are false by default
var options = {};
- for (var letter in map) {
- if (map[letter][0] !== '!')
- options[map[letter]] = false;
- }
+ Object.keys(map).forEach(function (letter) {
+ var optName = map[letter];
+ if (optName[0] !== '!') {
+ options[optName] = false;
+ }
+ });
- if (!opt)
- return options; // defaults
+ if (opt === '') return options; // defaults
- var optionName;
if (typeof opt === 'string') {
- if (opt[0] !== '-')
- return options;
+ if (opt[0] !== '-') {
+ error("Options string must start with a '-'", errorOptions || {});
+ }
// e.g. chars = ['R', 'f']
var chars = opt.slice(1).split('');
- chars.forEach(function(c) {
+ chars.forEach(function (c) {
if (c in map) {
- optionName = map[c];
- if (optionName[0] === '!')
- options[optionName.slice(1, optionName.length-1)] = false;
- else
+ var optionName = map[c];
+ if (optionName[0] === '!') {
+ options[optionName.slice(1)] = false;
+ } else {
options[optionName] = true;
+ }
} else {
- error('option not recognized: '+c);
+ error('option not recognized: ' + c, errorOptions || {});
}
});
- } else if (typeof opt === 'object') {
- for (var key in opt) {
+ } else { // opt is an Object
+ Object.keys(opt).forEach(function (key) {
// key is a string of the form '-r', '-d', etc.
var c = key[1];
if (c in map) {
- optionName = map[c];
+ var optionName = map[c];
options[optionName] = opt[key]; // assign the given value
} else {
- error('option not recognized: '+c);
+ error('option not recognized: ' + c, errorOptions || {});
}
- }
- } else {
- error('options must be strings or key-value pairs');
+ });
}
return options;
}
@@ -127,29 +251,18 @@ exports.parseOptions = parseOptions;
// expand(['file*.js']) = ['file1.js', 'file2.js', ...]
// (if the files 'file1.js', 'file2.js', etc, exist in the current dir)
function expand(list) {
+ if (!Array.isArray(list)) {
+ throw new TypeError('must be an array');
+ }
var expanded = [];
- list.forEach(function(listEl) {
- // Wildcard present on directory names ?
- if(listEl.search(/\*[^\/]*\//) > -1 || listEl.search(/\*\*[^\/]*\//) > -1) {
- var match = listEl.match(/^([^*]+\/|)(.*)/);
- var root = match[1];
- var rest = match[2];
- var restRegex = rest.replace(/\*\*/g, ".*").replace(/\*/g, "[^\\/]*");
- restRegex = new RegExp(restRegex);
-
- _ls('-R', root).filter(function (e) {
- return restRegex.test(e);
- }).forEach(function(file) {
- expanded.push(file);
- });
- }
- // Wildcard present on file names ?
- else if (listEl.search(/\*/) > -1) {
- _ls('', listEl).forEach(function(file) {
- expanded.push(file);
- });
- } else {
+ list.forEach(function (listEl) {
+ // Don't expand non-strings
+ if (typeof listEl !== 'string') {
expanded.push(listEl);
+ } else {
+ var ret = glob.sync(listEl, config.globOptions);
+ // if glob fails, interpret the string literally
+ expanded = expanded.concat(ret.length > 0 ? ret : [listEl]);
}
});
return expanded;
@@ -161,8 +274,9 @@ exports.expand = expand;
function unlinkSync(file) {
try {
fs.unlinkSync(file);
- } catch(e) {
+ } catch (e) {
// Try to override file permission
+ /* istanbul ignore next */
if (e.code === 'EPERM') {
fs.chmodSync(file, '0666');
fs.unlinkSync(file);
@@ -176,78 +290,120 @@ exports.unlinkSync = unlinkSync;
// e.g. 'shelljs_a5f185d0443ca...'
function randomFileName() {
function randomHash(count) {
- if (count === 1)
- return parseInt(16*Math.random(), 10).toString(16);
- else {
- var hash = '';
- for (var i=0; i<count; i++)
- hash += randomHash(1);
- return hash;
+ if (count === 1) {
+ return parseInt(16 * Math.random(), 10).toString(16);
+ }
+ var hash = '';
+ for (var i = 0; i < count; i++) {
+ hash += randomHash(1);
}
+ return hash;
}
- return 'shelljs_'+randomHash(20);
+ return 'shelljs_' + randomHash(20);
}
exports.randomFileName = randomFileName;
-// extend(target_obj, source_obj1 [, source_obj2 ...])
-// Shallow extend, e.g.:
-// extend({A:1}, {b:2}, {c:3}) returns {A:1, b:2, c:3}
-function extend(target) {
- var sources = [].slice.call(arguments, 1);
- sources.forEach(function(source) {
- for (var key in source)
- target[key] = source[key];
- });
-
- return target;
-}
-exports.extend = extend;
-
-// Common wrapper for all Unix-like commands
+// Common wrapper for all Unix-like commands that performs glob expansion,
+// command-logging, and other nice things
function wrap(cmd, fn, options) {
- return function() {
+ options = options || {};
+ if (options.canReceivePipe) {
+ pipeMethods.push(cmd);
+ }
+ return function () {
var retValue = null;
state.currentCmd = cmd;
state.error = null;
+ state.errorCode = 0;
try {
var args = [].slice.call(arguments, 0);
+ // Log the command to stderr, if appropriate
if (config.verbose) {
- args.unshift(cmd);
- console.log.apply(console, args);
- args.shift();
+ console.error.apply(console, [cmd].concat(args));
}
- if (options && options.notUnix) {
+ // If this is coming from a pipe, let's set the pipedValue (otherwise, set
+ // it to the empty string)
+ state.pipedValue = (this && typeof this.stdout === 'string') ? this.stdout : '';
+
+ if (options.unix === false) { // this branch is for exec()
retValue = fn.apply(this, args);
- } else {
- if (typeof args[0] === 'object' && args[0].constructor.name === 'Object') {
- args = args; // object count as options
+ } else { // and this branch is for everything else
+ if (isObject(args[0]) && args[0].constructor.name === 'Object') {
+ // a no-op, allowing the syntax `touch({'-r': file}, ...)`
} else if (args.length === 0 || typeof args[0] !== 'string' || args[0].length <= 1 || args[0][0] !== '-') {
args.unshift(''); // only add dummy option if '-option' not already present
}
+
+ // flatten out arrays that are arguments, to make the syntax:
+ // `cp([file1, file2, file3], dest);`
+ // equivalent to:
+ // `cp(file1, file2, file3, dest);`
+ args = args.reduce(function (accum, cur) {
+ if (Array.isArray(cur)) {
+ return accum.concat(cur);
+ }
+ accum.push(cur);
+ return accum;
+ }, []);
+
+ // Convert ShellStrings (basically just String objects) to regular strings
+ args = args.map(function (arg) {
+ if (isObject(arg) && arg.constructor.name === 'String') {
+ return arg.toString();
+ }
+ return arg;
+ });
+
// Expand the '~' if appropriate
var homeDir = getUserHome();
- args = args.map(function(arg) {
- if (typeof arg === 'string' && arg.slice(0, 2) === '~/' || arg === '~')
+ args = args.map(function (arg) {
+ if (typeof arg === 'string' && arg.slice(0, 2) === '~/' || arg === '~') {
return arg.replace(/^~/, homeDir);
- else
- return arg;
+ }
+ return arg;
});
- retValue = fn.apply(this, args);
+
+ // Perform glob-expansion on all arguments after globStart, but preserve
+ // the arguments before it (like regexes for sed and grep)
+ if (!config.noglob && options.allowGlobbing === true) {
+ args = args.slice(0, options.globStart).concat(expand(args.slice(options.globStart)));
+ }
+
+ try {
+ // parse options if options are provided
+ if (isObject(options.cmdOptions)) {
+ args[0] = parseOptions(args[0], options.cmdOptions);
+ }
+
+ retValue = fn.apply(this, args);
+ } catch (e) {
+ /* istanbul ignore else */
+ if (e.msg === 'earlyExit') {
+ retValue = e.retValue;
+ } else {
+ throw e; // this is probably a bug that should be thrown up the call stack
+ }
+ }
}
} catch (e) {
+ /* istanbul ignore next */
if (!state.error) {
// If state.error hasn't been set it's an error thrown by Node, not us - probably a bug...
- console.log('shell.js: internal error');
- console.log(e.stack || e);
+ console.error('ShellJS: internal error');
+ console.error(e.stack || e);
process.exit(1);
}
- if (config.fatal)
- throw e;
+ if (config.fatal) throw e;
+ }
+
+ if (options.wrapOutput &&
+ (typeof retValue === 'string' || Array.isArray(retValue))) {
+ retValue = new ShellString(retValue, state.error, state.errorCode);
}
state.currentCmd = 'shell.js';
@@ -255,3 +411,40 @@ function wrap(cmd, fn, options) {
};
} // wrap
exports.wrap = wrap;
+
+// This returns all the input that is piped into the current command (or the
+// empty string, if this isn't on the right-hand side of a pipe
+function _readFromPipe() {
+ return state.pipedValue;
+}
+exports.readFromPipe = _readFromPipe;
+
+var DEFAULT_WRAP_OPTIONS = {
+ allowGlobbing: true,
+ canReceivePipe: false,
+ cmdOptions: false,
+ globStart: 1,
+ pipeOnly: false,
+ unix: true,
+ wrapOutput: true,
+ overWrite: false,
+};
+
+// Register a new ShellJS command
+function _register(name, implementation, wrapOptions) {
+ wrapOptions = wrapOptions || {};
+ // If an option isn't specified, use the default
+ wrapOptions = objectAssign({}, DEFAULT_WRAP_OPTIONS, wrapOptions);
+
+ if (shell[name] && !wrapOptions.overWrite) {
+ throw new Error('unable to overwrite `' + name + '` command');
+ }
+
+ if (wrapOptions.pipeOnly) {
+ wrapOptions.canReceivePipe = true;
+ shellMethods[name] = wrap(name, implementation, wrapOptions);
+ } else {
+ shell[name] = wrap(name, implementation, wrapOptions);
+ }
+}
+exports.register = _register;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/cp.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/cp.js b/node_modules/shelljs/src/cp.js
index 54404ef..04c4e57 100644
--- a/node_modules/shelljs/src/cp.js
+++ b/node_modules/shelljs/src/cp.js
@@ -3,42 +3,79 @@ var path = require('path');
var common = require('./common');
var os = require('os');
+common.register('cp', _cp, {
+ cmdOptions: {
+ 'f': '!no_force',
+ 'n': 'no_force',
+ 'u': 'update',
+ 'R': 'recursive',
+ 'r': 'recursive',
+ 'L': 'followsymlink',
+ 'P': 'noFollowsymlink',
+ },
+ wrapOutput: false,
+});
+
// Buffered file copy, synchronous
// (Using readFileSync() + writeFileSync() could easily cause a memory overflow
// with large files)
-function copyFileSync(srcFile, destFile) {
- if (!fs.existsSync(srcFile))
+function copyFileSync(srcFile, destFile, options) {
+ if (!fs.existsSync(srcFile)) {
common.error('copyFileSync: no such file or directory: ' + srcFile);
-
- var BUF_LENGTH = 64*1024,
- buf = new Buffer(BUF_LENGTH),
- bytesRead = BUF_LENGTH,
- pos = 0,
- fdr = null,
- fdw = null;
-
- try {
- fdr = fs.openSync(srcFile, 'r');
- } catch(e) {
- common.error('copyFileSync: could not read src file ('+srcFile+')');
}
+ // Check the mtimes of the files if the '-u' flag is provided
try {
- fdw = fs.openSync(destFile, 'w');
- } catch(e) {
- common.error('copyFileSync: could not write to dest file (code='+e.code+'):'+destFile);
+ if (options.update && fs.statSync(srcFile).mtime < fs.statSync(destFile).mtime) {
+ return;
+ }
+ } catch (e) {
+ // If we're here, destFile probably doesn't exist, so just do a normal copy
}
- while (bytesRead === BUF_LENGTH) {
- bytesRead = fs.readSync(fdr, buf, 0, BUF_LENGTH, pos);
- fs.writeSync(fdw, buf, 0, bytesRead);
- pos += bytesRead;
- }
+ if (fs.lstatSync(srcFile).isSymbolicLink() && !options.followsymlink) {
+ try {
+ fs.lstatSync(destFile);
+ common.unlinkSync(destFile); // re-link it
+ } catch (e) {
+ // it doesn't exist, so no work needs to be done
+ }
- fs.closeSync(fdr);
- fs.closeSync(fdw);
+ var symlinkFull = fs.readlinkSync(srcFile);
+ fs.symlinkSync(symlinkFull, destFile, os.platform() === 'win32' ? 'junction' : null);
+ } else {
+ var BUF_LENGTH = 64 * 1024;
+ var buf = new Buffer(BUF_LENGTH);
+ var bytesRead = BUF_LENGTH;
+ var pos = 0;
+ var fdr = null;
+ var fdw = null;
- fs.chmodSync(destFile, fs.statSync(srcFile).mode);
+ try {
+ fdr = fs.openSync(srcFile, 'r');
+ } catch (e) {
+ /* istanbul ignore next */
+ common.error('copyFileSync: could not read src file (' + srcFile + ')');
+ }
+
+ try {
+ fdw = fs.openSync(destFile, 'w');
+ } catch (e) {
+ /* istanbul ignore next */
+ common.error('copyFileSync: could not write to dest file (code=' + e.code + '):' + destFile);
+ }
+
+ while (bytesRead === BUF_LENGTH) {
+ bytesRead = fs.readSync(fdr, buf, 0, BUF_LENGTH, pos);
+ fs.writeSync(fdw, buf, 0, bytesRead);
+ pos += bytesRead;
+ }
+
+ fs.closeSync(fdr);
+ fs.closeSync(fdw);
+
+ fs.chmodSync(destFile, fs.statSync(srcFile).mode);
+ }
}
// Recursively copies 'sourceDir' into 'destDir'
@@ -49,43 +86,91 @@ function copyFileSync(srcFile, destFile) {
//
// Licensed under the MIT License
// http://www.opensource.org/licenses/mit-license.php
-function cpdirSyncRecursive(sourceDir, destDir, opts) {
+function cpdirSyncRecursive(sourceDir, destDir, currentDepth, opts) {
if (!opts) opts = {};
- /* Create the directory where all our junk is moving to; read the mode of the source directory and mirror it */
- var checkDir = fs.statSync(sourceDir);
+ // Ensure there is not a run away recursive copy
+ if (currentDepth >= common.config.maxdepth) return;
+ currentDepth++;
+
+ // Create the directory where all our junk is moving to; read the mode of the
+ // source directory and mirror it
try {
+ var checkDir = fs.statSync(sourceDir);
fs.mkdirSync(destDir, checkDir.mode);
} catch (e) {
- //if the directory already exists, that's okay
+ // if the directory already exists, that's okay
if (e.code !== 'EEXIST') throw e;
}
var files = fs.readdirSync(sourceDir);
for (var i = 0; i < files.length; i++) {
- var srcFile = sourceDir + "/" + files[i];
- var destFile = destDir + "/" + files[i];
+ var srcFile = sourceDir + '/' + files[i];
+ var destFile = destDir + '/' + files[i];
var srcFileStat = fs.lstatSync(srcFile);
+ var symlinkFull;
+ if (opts.followsymlink) {
+ if (cpcheckcycle(sourceDir, srcFile)) {
+ // Cycle link found.
+ console.error('Cycle link found.');
+ symlinkFull = fs.readlinkSync(srcFile);
+ fs.symlinkSync(symlinkFull, destFile, os.platform() === 'win32' ? 'junction' : null);
+ continue;
+ }
+ }
if (srcFileStat.isDirectory()) {
/* recursion this thing right on back. */
- cpdirSyncRecursive(srcFile, destFile, opts);
- } else if (srcFileStat.isSymbolicLink()) {
- var symlinkFull = fs.readlinkSync(srcFile);
- fs.symlinkSync(symlinkFull, destFile, os.platform() === "win32" ? "junction" : null);
+ cpdirSyncRecursive(srcFile, destFile, currentDepth, opts);
+ } else if (srcFileStat.isSymbolicLink() && !opts.followsymlink) {
+ symlinkFull = fs.readlinkSync(srcFile);
+ try {
+ fs.lstatSync(destFile);
+ common.unlinkSync(destFile); // re-link it
+ } catch (e) {
+ // it doesn't exist, so no work needs to be done
+ }
+ fs.symlinkSync(symlinkFull, destFile, os.platform() === 'win32' ? 'junction' : null);
+ } else if (srcFileStat.isSymbolicLink() && opts.followsymlink) {
+ srcFileStat = fs.statSync(srcFile);
+ if (srcFileStat.isDirectory()) {
+ cpdirSyncRecursive(srcFile, destFile, currentDepth, opts);
+ } else {
+ copyFileSync(srcFile, destFile, opts);
+ }
} else {
/* At this point, we've hit a file actually worth copying... so copy it on over. */
if (fs.existsSync(destFile) && opts.no_force) {
common.log('skipping existing file: ' + files[i]);
} else {
- copyFileSync(srcFile, destFile);
+ copyFileSync(srcFile, destFile, opts);
}
}
-
} // for files
} // cpdirSyncRecursive
+function cpcheckcycle(sourceDir, srcFile) {
+ var srcFileStat = fs.lstatSync(srcFile);
+ if (srcFileStat.isSymbolicLink()) {
+ // Do cycle check. For example:
+ // $ mkdir -p 1/2/3/4
+ // $ cd 1/2/3/4
+ // $ ln -s ../../3 link
+ // $ cd ../../../..
+ // $ cp -RL 1 copy
+ var cyclecheck = fs.statSync(srcFile);
+ if (cyclecheck.isDirectory()) {
+ var sourcerealpath = fs.realpathSync(sourceDir);
+ var symlinkrealpath = fs.realpathSync(srcFile);
+ var re = new RegExp(symlinkrealpath);
+ if (re.test(sourcerealpath)) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
//@
//@ ### cp([options,] source [, source ...], dest)
@@ -94,117 +179,100 @@ function cpdirSyncRecursive(sourceDir, destDir, opts) {
//@
//@ + `-f`: force (default behavior)
//@ + `-n`: no-clobber
-//@ + `-r, -R`: recursive
+//@ + `-u`: only copy if source is newer than dest
+//@ + `-r`, `-R`: recursive
+//@ + `-L`: follow symlinks
+//@ + `-P`: don't follow symlinks
//@
//@ Examples:
//@
//@ ```javascript
//@ cp('file1', 'dir1');
+//@ cp('-R', 'path/to/dir/', '~/newCopy/');
//@ cp('-Rf', '/tmp/*', '/usr/local/*', '/home/tmp');
//@ cp('-Rf', ['/tmp/*', '/usr/local/*'], '/home/tmp'); // same as above
//@ ```
//@
-//@ Copies files. The wildcard `*` is accepted.
+//@ Copies files.
function _cp(options, sources, dest) {
- options = common.parseOptions(options, {
- 'f': '!no_force',
- 'n': 'no_force',
- 'R': 'recursive',
- 'r': 'recursive'
- });
+ // If we're missing -R, it actually implies -L (unless -P is explicit)
+ if (options.followsymlink) {
+ options.noFollowsymlink = false;
+ }
+ if (!options.recursive && !options.noFollowsymlink) {
+ options.followsymlink = true;
+ }
// Get sources, dest
if (arguments.length < 3) {
common.error('missing <source> and/or <dest>');
- } else if (arguments.length > 3) {
+ } else {
sources = [].slice.call(arguments, 1, arguments.length - 1);
dest = arguments[arguments.length - 1];
- } else if (typeof sources === 'string') {
- sources = [sources];
- } else if ('length' in sources) {
- sources = sources; // no-op for array
- } else {
- common.error('invalid arguments');
}
- var exists = fs.existsSync(dest),
- stats = exists && fs.statSync(dest);
+ var destExists = fs.existsSync(dest);
+ var destStat = destExists && fs.statSync(dest);
// Dest is not existing dir, but multiple sources given
- if ((!exists || !stats.isDirectory()) && sources.length > 1)
+ if ((!destExists || !destStat.isDirectory()) && sources.length > 1) {
common.error('dest is not a directory (too many sources)');
-
- // Dest is an existing file, but no -f given
- if (exists && stats.isFile() && options.no_force)
- common.error('dest file already exists: ' + dest);
-
- if (options.recursive) {
- // Recursive allows the shortcut syntax "sourcedir/" for "sourcedir/*"
- // (see Github issue #15)
- sources.forEach(function(src, i) {
- if (src[src.length - 1] === '/') {
- sources[i] += '*';
- // If src is a directory and dest doesn't exist, 'cp -r src dest' should copy src/* into dest
- } else if (fs.statSync(src).isDirectory() && !exists) {
- sources[i] += '/*';
- }
- });
-
- // Create dest
- try {
- fs.mkdirSync(dest, parseInt('0777', 8));
- } catch (e) {
- // like Unix's cp, keep going even if we can't create dest dir
- }
}
- sources = common.expand(sources);
+ // Dest is an existing file, but -n is given
+ if (destExists && destStat.isFile() && options.no_force) {
+ return new common.ShellString('', '', 0);
+ }
- sources.forEach(function(src) {
+ sources.forEach(function (src) {
if (!fs.existsSync(src)) {
- common.error('no such file or directory: '+src, true);
+ common.error('no such file or directory: ' + src, { continue: true });
return; // skip file
}
-
- // If here, src exists
- if (fs.statSync(src).isDirectory()) {
+ var srcStat = fs.statSync(src);
+ if (!options.noFollowsymlink && srcStat.isDirectory()) {
if (!options.recursive) {
// Non-Recursive
- common.log(src + ' is a directory (not copied)');
+ common.error("omitting directory '" + src + "'", { continue: true });
} else {
// Recursive
// 'cp /a/source dest' should create 'source' in 'dest'
- var newDest = path.join(dest, path.basename(src)),
- checkDir = fs.statSync(src);
+ var newDest = (destStat && destStat.isDirectory()) ?
+ path.join(dest, path.basename(src)) :
+ dest;
+
try {
- fs.mkdirSync(newDest, checkDir.mode);
+ fs.statSync(path.dirname(dest));
+ cpdirSyncRecursive(src, newDest, 0, { no_force: options.no_force, followsymlink: options.followsymlink });
} catch (e) {
- //if the directory already exists, that's okay
- if (e.code !== 'EEXIST') {
- common.error('dest file no such file or directory: ' + newDest, true);
- throw e;
- }
+ /* istanbul ignore next */
+ common.error("cannot create directory '" + dest + "': No such file or directory");
}
+ }
+ } else {
+ // If here, src is a file
- cpdirSyncRecursive(src, newDest, {no_force: options.no_force});
+ // When copying to '/path/dir':
+ // thisDest = '/path/dir/file1'
+ var thisDest = dest;
+ if (destStat && destStat.isDirectory()) {
+ thisDest = path.normalize(dest + '/' + path.basename(src));
}
- return; // done with dir
- }
- // If here, src is a file
+ if (fs.existsSync(thisDest) && options.no_force) {
+ return; // skip file
+ }
- // When copying to '/path/dir':
- // thisDest = '/path/dir/file1'
- var thisDest = dest;
- if (fs.existsSync(dest) && fs.statSync(dest).isDirectory())
- thisDest = path.normalize(dest + '/' + path.basename(src));
+ if (path.relative(src, thisDest) === '') {
+ // a file cannot be copied to itself, but we want to continue copying other files
+ common.error("'" + thisDest + "' and '" + src + "' are the same file", { continue: true });
+ return;
+ }
- if (fs.existsSync(thisDest) && options.no_force) {
- common.error('dest file already exists: ' + thisDest, true);
- return; // skip file
+ copyFileSync(src, thisDest, options);
}
-
- copyFileSync(src, thisDest);
}); // forEach(src)
+
+ return new common.ShellString('', common.state.error, common.state.errorCode);
}
module.exports = _cp;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/dirs.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/dirs.js b/node_modules/shelljs/src/dirs.js
index 58fae8b..3806c14 100644
--- a/node_modules/shelljs/src/dirs.js
+++ b/node_modules/shelljs/src/dirs.js
@@ -2,6 +2,16 @@ var common = require('./common');
var _cd = require('./cd');
var path = require('path');
+common.register('dirs', _dirs, {
+ wrapOutput: false,
+});
+common.register('pushd', _pushd, {
+ wrapOutput: false,
+});
+common.register('popd', _popd, {
+ wrapOutput: false,
+});
+
// Pushd/popd/dirs internals
var _dirStack = [];
@@ -13,9 +23,8 @@ function _parseStackIndex(index) {
if (_isStackIndex(index)) {
if (Math.abs(index) < _dirStack.length + 1) { // +1 for pwd
return (/^-/).test(index) ? Number(index) - 1 : Number(index);
- } else {
- common.error(index + ': directory stack index out of range');
}
+ common.error(index + ': directory stack index out of range');
} else {
common.error(index + ': invalid number');
}
@@ -54,7 +63,7 @@ function _pushd(options, dir) {
}
options = common.parseOptions(options, {
- 'n' : 'no-cd'
+ 'n': 'no-cd',
});
var dirs = _actualDirStack();
@@ -120,7 +129,7 @@ function _popd(options, index) {
}
options = common.parseOptions(options, {
- 'n' : 'no-cd'
+ 'n': 'no-cd',
});
if (!_dirStack.length) {
@@ -163,10 +172,10 @@ function _dirs(options, index) {
}
options = common.parseOptions(options, {
- 'c' : 'clear'
+ 'c': 'clear',
});
- if (options['clear']) {
+ if (options.clear) {
_dirStack = [];
return _dirStack;
}
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/echo.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/echo.js b/node_modules/shelljs/src/echo.js
index b574adc..2b0e7d9 100644
--- a/node_modules/shelljs/src/echo.js
+++ b/node_modules/shelljs/src/echo.js
@@ -1,7 +1,14 @@
var common = require('./common');
+common.register('echo', _echo, {
+ allowGlobbing: false,
+});
+
+//@
+//@ ### echo([options,] string [, string ...])
+//@ Available options:
//@
-//@ ### echo(string [, string ...])
+//@ + `-e`: interpret backslash escapes (default)
//@
//@ Examples:
//@
@@ -12,9 +19,16 @@ var common = require('./common');
//@
//@ Prints string to stdout, and returns string with additional utility methods
//@ like `.to()`.
-function _echo() {
- var messages = [].slice.call(arguments, 0);
+function _echo(opts, messages) {
+ // allow strings starting with '-', see issue #20
+ messages = [].slice.call(arguments, opts ? 0 : 1);
+
+ if (messages[0] === '-e') {
+ // ignore -e
+ messages.shift();
+ }
+
console.log.apply(console, messages);
- return common.ShellString(messages.join(' '));
+ return messages.join(' ');
}
module.exports = _echo;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/error.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/error.js b/node_modules/shelljs/src/error.js
index 112563d..507c86d 100644
--- a/node_modules/shelljs/src/error.js
+++ b/node_modules/shelljs/src/error.js
@@ -2,8 +2,12 @@ var common = require('./common');
//@
//@ ### error()
-//@ Tests if error occurred in the last command. Returns `null` if no error occurred,
-//@ otherwise returns string explaining the error
+//@ Tests if error occurred in the last command. Returns a truthy value if an
+//@ error returned and a falsy value otherwise.
+//@
+//@ **Note**: do not rely on the
+//@ return value to be an error message. If you need the last error message, use
+//@ the `.stderr` attribute from the last command's return value instead.
function error() {
return common.state.error;
}
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/exec.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/exec.js b/node_modules/shelljs/src/exec.js
index 4174adb..5d360e8 100644
--- a/node_modules/shelljs/src/exec.js
+++ b/node_modules/shelljs/src/exec.js
@@ -5,85 +5,106 @@ var path = require('path');
var fs = require('fs');
var child = require('child_process');
-var DEFAULT_MAXBUFFER_SIZE = 20*1024*1024;
+var DEFAULT_MAXBUFFER_SIZE = 20 * 1024 * 1024;
+
+common.register('exec', _exec, {
+ unix: false,
+ canReceivePipe: true,
+ wrapOutput: false,
+});
// Hack to run child_process.exec() synchronously (sync avoids callback hell)
// Uses a custom wait loop that checks for a flag file, created when the child process is done.
// (Can't do a wait loop that checks for internal Node variables/messages as
// Node is single-threaded; callbacks and other internal state changes are done in the
// event loop).
-function execSync(cmd, opts) {
+function execSync(cmd, opts, pipe) {
+ if (!common.config.execPath) {
+ common.error('Unable to find a path to the node binary. Please manually set config.execPath');
+ }
+
var tempDir = _tempDir();
- var stdoutFile = path.resolve(tempDir+'/'+common.randomFileName()),
- stderrFile = path.resolve(tempDir+'/'+common.randomFileName()),
- codeFile = path.resolve(tempDir+'/'+common.randomFileName()),
- scriptFile = path.resolve(tempDir+'/'+common.randomFileName()),
- sleepFile = path.resolve(tempDir+'/'+common.randomFileName());
+ var stdoutFile = path.resolve(tempDir + '/' + common.randomFileName());
+ var stderrFile = path.resolve(tempDir + '/' + common.randomFileName());
+ var codeFile = path.resolve(tempDir + '/' + common.randomFileName());
+ var scriptFile = path.resolve(tempDir + '/' + common.randomFileName());
+ var sleepFile = path.resolve(tempDir + '/' + common.randomFileName());
opts = common.extend({
silent: common.config.silent,
- cwd: _pwd(),
+ cwd: _pwd().toString(),
env: process.env,
- maxBuffer: DEFAULT_MAXBUFFER_SIZE
+ maxBuffer: DEFAULT_MAXBUFFER_SIZE,
}, opts);
- var previousStdoutContent = '',
- previousStderrContent = '';
+ var previousStdoutContent = '';
+ var previousStderrContent = '';
// Echoes stdout and stderr changes from running process, if not silent
function updateStream(streamFile) {
- if (opts.silent || !fs.existsSync(streamFile))
+ if (opts.silent || !fs.existsSync(streamFile)) {
return;
+ }
- var previousStreamContent,
- proc_stream;
+ var previousStreamContent;
+ var procStream;
if (streamFile === stdoutFile) {
previousStreamContent = previousStdoutContent;
- proc_stream = process.stdout;
+ procStream = process.stdout;
} else { // assume stderr
previousStreamContent = previousStderrContent;
- proc_stream = process.stderr;
+ procStream = process.stderr;
}
var streamContent = fs.readFileSync(streamFile, 'utf8');
// No changes since last time?
- if (streamContent.length <= previousStreamContent.length)
+ if (streamContent.length <= previousStreamContent.length) {
return;
+ }
- proc_stream.write(streamContent.substr(previousStreamContent.length));
+ procStream.write(streamContent.substr(previousStreamContent.length));
previousStreamContent = streamContent;
}
- function escape(str) {
- return (str+'').replace(/([\\"'])/g, "\\$1").replace(/\0/g, "\\0");
- }
-
if (fs.existsSync(scriptFile)) common.unlinkSync(scriptFile);
if (fs.existsSync(stdoutFile)) common.unlinkSync(stdoutFile);
if (fs.existsSync(stderrFile)) common.unlinkSync(stderrFile);
if (fs.existsSync(codeFile)) common.unlinkSync(codeFile);
- var execCommand = '"'+process.execPath+'" '+scriptFile;
+ var execCommand = JSON.stringify(common.config.execPath) + ' ' + JSON.stringify(scriptFile);
var script;
+ opts.cwd = path.resolve(opts.cwd);
+ var optString = JSON.stringify(opts);
+
if (typeof child.execSync === 'function') {
script = [
"var child = require('child_process')",
" , fs = require('fs');",
- "var childProcess = child.exec('"+escape(cmd)+"', {env: process.env, maxBuffer: "+opts.maxBuffer+"}, function(err) {",
- " fs.writeFileSync('"+escape(codeFile)+"', err ? err.code.toString() : '0');",
- "});",
- "var stdoutStream = fs.createWriteStream('"+escape(stdoutFile)+"');",
- "var stderrStream = fs.createWriteStream('"+escape(stderrFile)+"');",
- "childProcess.stdout.pipe(stdoutStream, {end: false});",
- "childProcess.stderr.pipe(stderrStream, {end: false});",
- "childProcess.stdout.pipe(process.stdout);",
- "childProcess.stderr.pipe(process.stderr);",
- "var stdoutEnded = false, stderrEnded = false;",
- "function tryClosingStdout(){ if(stdoutEnded){ stdoutStream.end(); } }",
- "function tryClosingStderr(){ if(stderrEnded){ stderrStream.end(); } }",
- "childProcess.stdout.on('end', function(){ stdoutEnded = true; tryClosingStdout(); });",
- "childProcess.stderr.on('end', function(){ stderrEnded = true; tryClosingStderr(); });"
- ].join('\n');
+ 'var childProcess = child.exec(' + JSON.stringify(cmd) + ', ' + optString + ', function(err) {',
+ ' var fname = ' + JSON.stringify(codeFile) + ';',
+ ' if (!err) {',
+ ' fs.writeFileSync(fname, "0");',
+ ' } else if (err.code === undefined) {',
+ ' fs.writeFileSync(fname, "1");',
+ ' } else {',
+ ' fs.writeFileSync(fname, err.code.toString());',
+ ' }',
+ '});',
+ 'var stdoutStream = fs.createWriteStream(' + JSON.stringify(stdoutFile) + ');',
+ 'var stderrStream = fs.createWriteStream(' + JSON.stringify(stderrFile) + ');',
+ 'childProcess.stdout.pipe(stdoutStream, {end: false});',
+ 'childProcess.stderr.pipe(stderrStream, {end: false});',
+ 'childProcess.stdout.pipe(process.stdout);',
+ 'childProcess.stderr.pipe(process.stderr);',
+ ].join('\n') +
+ (pipe ? '\nchildProcess.stdin.end(' + JSON.stringify(pipe) + ');\n' : '\n') +
+ [
+ 'var stdoutEnded = false, stderrEnded = false;',
+ 'function tryClosingStdout(){ if(stdoutEnded){ stdoutStream.end(); } }',
+ 'function tryClosingStderr(){ if(stderrEnded){ stderrStream.end(); } }',
+ "childProcess.stdout.on('end', function(){ stdoutEnded = true; tryClosingStdout(); });",
+ "childProcess.stderr.on('end', function(){ stderrEnded = true; tryClosingStderr(); });",
+ ].join('\n');
fs.writeFileSync(scriptFile, script);
@@ -94,17 +115,34 @@ function execSync(cmd, opts) {
}
// Welcome to the future
- child.execSync(execCommand, opts);
+ try {
+ child.execSync(execCommand, opts);
+ } catch (e) {
+ // Clean up immediately if we have an exception
+ try { common.unlinkSync(scriptFile); } catch (e2) {}
+ try { common.unlinkSync(stdoutFile); } catch (e2) {}
+ try { common.unlinkSync(stderrFile); } catch (e2) {}
+ try { common.unlinkSync(codeFile); } catch (e2) {}
+ throw e;
+ }
} else {
- cmd += ' > '+stdoutFile+' 2> '+stderrFile; // works on both win/unix
+ cmd += ' > ' + stdoutFile + ' 2> ' + stderrFile; // works on both win/unix
script = [
"var child = require('child_process')",
" , fs = require('fs');",
- "var childProcess = child.exec('"+escape(cmd)+"', {env: process.env, maxBuffer: "+opts.maxBuffer+"}, function(err) {",
- " fs.writeFileSync('"+escape(codeFile)+"', err ? err.code.toString() : '0');",
- "});"
- ].join('\n');
+ 'var childProcess = child.exec(' + JSON.stringify(cmd) + ', ' + optString + ', function(err) {',
+ ' var fname = ' + JSON.stringify(codeFile) + ';',
+ ' if (!err) {',
+ ' fs.writeFileSync(fname, "0");',
+ ' } else if (err.code === undefined) {',
+ ' fs.writeFileSync(fname, "1");',
+ ' } else {',
+ ' fs.writeFileSync(fname, err.code.toString());',
+ ' }',
+ '});',
+ ].join('\n') +
+ (pipe ? '\nchildProcess.stdin.end(' + JSON.stringify(pipe) + ');\n' : '\n');
fs.writeFileSync(scriptFile, script);
@@ -117,6 +155,7 @@ function execSync(cmd, opts) {
while (!fs.existsSync(codeFile)) { updateStream(stdoutFile); fs.writeFileSync(sleepFile, 'a'); }
while (!fs.existsSync(stdoutFile)) { updateStream(stdoutFile); fs.writeFileSync(sleepFile, 'a'); }
while (!fs.existsSync(stderrFile)) { updateStream(stderrFile); fs.writeFileSync(sleepFile, 'a'); }
+ try { common.unlinkSync(sleepFile); } catch (e) {}
}
// At this point codeFile exists, but it's not necessarily flushed yet.
@@ -130,53 +169,53 @@ function execSync(cmd, opts) {
var stderr = fs.readFileSync(stderrFile, 'utf8');
// No biggie if we can't erase the files now -- they're in a temp dir anyway
- try { common.unlinkSync(scriptFile); } catch(e) {}
- try { common.unlinkSync(stdoutFile); } catch(e) {}
- try { common.unlinkSync(stderrFile); } catch(e) {}
- try { common.unlinkSync(codeFile); } catch(e) {}
- try { common.unlinkSync(sleepFile); } catch(e) {}
-
- // some shell return codes are defined as errors, per http://tldp.org/LDP/abs/html/exitcodes.html
- if (code === 1 || code === 2 || code >= 126) {
- common.error('', true); // unix/shell doesn't really give an error message after non-zero exit codes
+ try { common.unlinkSync(scriptFile); } catch (e) {}
+ try { common.unlinkSync(stdoutFile); } catch (e) {}
+ try { common.unlinkSync(stderrFile); } catch (e) {}
+ try { common.unlinkSync(codeFile); } catch (e) {}
+
+ if (code !== 0) {
+ common.error('', code, { continue: true });
}
- // True if successful, false if not
- var obj = {
- code: code,
- output: stdout, // deprecated
- stdout: stdout,
- stderr: stderr
- };
+ var obj = common.ShellString(stdout, stderr, code);
return obj;
} // execSync()
// Wrapper around exec() to enable echoing output to console in real time
-function execAsync(cmd, opts, callback) {
+function execAsync(cmd, opts, pipe, callback) {
var stdout = '';
var stderr = '';
opts = common.extend({
silent: common.config.silent,
- cwd: _pwd(),
+ cwd: _pwd().toString(),
env: process.env,
- maxBuffer: DEFAULT_MAXBUFFER_SIZE
+ maxBuffer: DEFAULT_MAXBUFFER_SIZE,
}, opts);
- var c = child.exec(cmd, opts, function(err) {
- if (callback)
- callback(err ? err.code : 0, stdout, stderr);
+ var c = child.exec(cmd, opts, function (err) {
+ if (callback) {
+ if (!err) {
+ callback(0, stdout, stderr);
+ } else if (err.code === undefined) {
+ // See issue #536
+ callback(1, stdout, stderr);
+ } else {
+ callback(err.code, stdout, stderr);
+ }
+ }
});
- c.stdout.on('data', function(data) {
+ if (pipe) c.stdin.end(pipe);
+
+ c.stdout.on('data', function (data) {
stdout += data;
- if (!opts.silent)
- process.stdout.write(data);
+ if (!opts.silent) process.stdout.write(data);
});
- c.stderr.on('data', function(data) {
+ c.stderr.on('data', function (data) {
stderr += data;
- if (!opts.silent)
- process.stderr.write(data);
+ if (!opts.silent) process.stderr.write(data);
});
return c;
@@ -189,7 +228,7 @@ function execAsync(cmd, opts, callback) {
//@ + `async`: Asynchronous execution. If a callback is provided, it will be set to
//@ `true`, regardless of the passed value.
//@ + `silent`: Do not echo program output to console.
-//@ + and any option available to NodeJS's
+//@ + and any option available to Node.js's
//@ [child_process.exec()](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback)
//@
//@ Examples:
@@ -210,16 +249,22 @@ function execAsync(cmd, opts, callback) {
//@ ```
//@
//@ Executes the given `command` _synchronously_, unless otherwise specified. When in synchronous
-//@ mode returns the object `{ code:..., stdout:... , stderr:... }`, containing the program's
-//@ `stdout`, `stderr`, and its exit `code`. Otherwise returns the child process object,
-//@ and the `callback` gets the arguments `(code, stdout, stderr)`.
+//@ mode, this returns a ShellString (compatible with ShellJS v0.6.x, which returns an object
+//@ of the form `{ code:..., stdout:... , stderr:... }`). Otherwise, this returns the child process
+//@ object, and the `callback` gets the arguments `(code, stdout, stderr)`.
+//@
+//@ Not seeing the behavior you want? `exec()` runs everything through `sh`
+//@ by default (or `cmd.exe` on Windows), which differs from `bash`. If you
+//@ need bash-specific behavior, try out the `{shell: 'path/to/bash'}` option.
//@
//@ **Note:** For long-lived processes, it's best to run `exec()` asynchronously as
//@ the current synchronous implementation uses a lot of CPU. This should be getting
//@ fixed soon.
function _exec(command, options, callback) {
- if (!command)
- common.error('must specify command');
+ options = options || {};
+ if (!command) common.error('must specify command');
+
+ var pipe = common.readFromPipe();
// Callback is defined instead of options.
if (typeof options === 'function') {
@@ -234,14 +279,15 @@ function _exec(command, options, callback) {
options = common.extend({
silent: common.config.silent,
- async: false
+ async: false,
}, options);
try {
- if (options.async)
- return execAsync(command, options, callback);
- else
- return execSync(command, options);
+ if (options.async) {
+ return execAsync(command, options, pipe, callback);
+ } else {
+ return execSync(command, options, pipe);
+ }
} catch (e) {
common.error('internal error');
}
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/find.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/find.js b/node_modules/shelljs/src/find.js
index c96fb2f..625aa29 100644
--- a/node_modules/shelljs/src/find.js
+++ b/node_modules/shelljs/src/find.js
@@ -1,7 +1,10 @@
var fs = require('fs');
+var path = require('path');
var common = require('./common');
var _ls = require('./ls');
+common.register('find', _find, {});
+
//@
//@ ### find(path [, path ...])
//@ ### find(path_array)
@@ -18,30 +21,37 @@ var _ls = require('./ls');
//@ The main difference from `ls('-R', path)` is that the resulting file names
//@ include the base directories, e.g. `lib/resources/file1` instead of just `file1`.
function _find(options, paths) {
- if (!paths)
+ if (!paths) {
common.error('no path specified');
- else if (typeof paths === 'object')
- paths = paths; // assume array
- else if (typeof paths === 'string')
+ } else if (typeof paths === 'string') {
paths = [].slice.call(arguments, 1);
+ }
var list = [];
function pushFile(file) {
- if (common.platform === 'win')
+ if (common.platform === 'win') {
file = file.replace(/\\/g, '/');
+ }
list.push(file);
}
// why not simply do ls('-R', paths)? because the output wouldn't give the base dirs
// to get the base dir in the output, we need instead ls('-R', 'dir/*') for every directory
- paths.forEach(function(file) {
+ paths.forEach(function (file) {
+ var stat;
+ try {
+ stat = fs.statSync(file);
+ } catch (e) {
+ common.error('no such file or directory: ' + file);
+ }
+
pushFile(file);
- if (fs.statSync(file).isDirectory()) {
- _ls('-RA', file+'/*').forEach(function(subfile) {
- pushFile(subfile);
+ if (stat.isDirectory()) {
+ _ls({ recursive: true, all: true }, file).forEach(function (subfile) {
+ pushFile(path.join(file, subfile));
});
}
});
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/grep.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/grep.js b/node_modules/shelljs/src/grep.js
index 78008ce..30842bc 100644
--- a/node_modules/shelljs/src/grep.js
+++ b/node_modules/shelljs/src/grep.js
@@ -1,12 +1,22 @@
var common = require('./common');
var fs = require('fs');
+common.register('grep', _grep, {
+ globStart: 2, // don't glob-expand the regex
+ canReceivePipe: true,
+ cmdOptions: {
+ 'v': 'inverse',
+ 'l': 'nameOnly',
+ },
+});
+
//@
//@ ### grep([options,] regex_filter, file [, file ...])
//@ ### grep([options,] regex_filter, file_array)
//@ Available options:
//@
//@ + `-v`: Inverse the sense of the regex and print the lines not matching the criteria.
+//@ + `-l`: Print only filenames of matching files
//@
//@ Examples:
//@
@@ -16,37 +26,42 @@ var fs = require('fs');
//@ ```
//@
//@ Reads input string from given files and returns a string containing all lines of the
-//@ file that match the given `regex_filter`. Wildcard `*` accepted.
+//@ file that match the given `regex_filter`.
function _grep(options, regex, files) {
- options = common.parseOptions(options, {
- 'v': 'inverse'
- });
+ // Check if this is coming from a pipe
+ var pipe = common.readFromPipe();
- if (!files)
- common.error('no paths given');
+ if (!files && !pipe) common.error('no paths given', 2);
- if (typeof files === 'string')
- files = [].slice.call(arguments, 2);
- // if it's array leave it as it is
+ files = [].slice.call(arguments, 2);
- files = common.expand(files);
+ if (pipe) {
+ files.unshift('-');
+ }
- var grep = '';
- files.forEach(function(file) {
- if (!fs.existsSync(file)) {
- common.error('no such file or directory: ' + file, true);
+ var grep = [];
+ files.forEach(function (file) {
+ if (!fs.existsSync(file) && file !== '-') {
+ common.error('no such file or directory: ' + file, 2, { continue: true });
return;
}
- var contents = fs.readFileSync(file, 'utf8'),
- lines = contents.split(/\r*\n/);
- lines.forEach(function(line) {
- var matched = line.match(regex);
- if ((options.inverse && !matched) || (!options.inverse && matched))
- grep += line + '\n';
- });
+ var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8');
+ var lines = contents.split(/\r*\n/);
+ if (options.nameOnly) {
+ if (contents.match(regex)) {
+ grep.push(file);
+ }
+ } else {
+ lines.forEach(function (line) {
+ var matched = line.match(regex);
+ if ((options.inverse && !matched) || (!options.inverse && matched)) {
+ grep.push(line);
+ }
+ });
+ }
});
- return common.ShellString(grep);
+ return grep.join('\n') + '\n';
}
module.exports = _grep;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/ln.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/ln.js b/node_modules/shelljs/src/ln.js
index 878fda1..7393d9f 100644
--- a/node_modules/shelljs/src/ln.js
+++ b/node_modules/shelljs/src/ln.js
@@ -2,6 +2,13 @@ var fs = require('fs');
var path = require('path');
var common = require('./common');
+common.register('ln', _ln, {
+ cmdOptions: {
+ 's': 'symlink',
+ 'f': 'force',
+ },
+});
+
//@
//@ ### ln([options,] source, dest)
//@ Available options:
@@ -18,11 +25,6 @@ var common = require('./common');
//@
//@ Links source to dest. Use -f to force the link, should dest already exist.
function _ln(options, source, dest) {
- options = common.parseOptions(options, {
- 's': 'symlink',
- 'f': 'force'
- });
-
if (!source || !dest) {
common.error('Missing <source> and/or <dest>');
}
@@ -34,7 +36,7 @@ function _ln(options, source, dest) {
if (fs.existsSync(dest)) {
if (!options.force) {
- common.error('Destination file exists', true);
+ common.error('Destination file exists', { continue: true });
}
fs.unlinkSync(dest);
@@ -45,19 +47,19 @@ function _ln(options, source, dest) {
var linkType = isWindows ? 'file' : null;
var resolvedSourcePath = isAbsolute ? sourcePath : path.resolve(process.cwd(), path.dirname(dest), source);
if (!fs.existsSync(resolvedSourcePath)) {
- common.error('Source file does not exist', true);
+ common.error('Source file does not exist', { continue: true });
} else if (isWindows && fs.statSync(resolvedSourcePath).isDirectory()) {
- linkType = 'junction';
+ linkType = 'junction';
}
try {
- fs.symlinkSync(linkType === 'junction' ? resolvedSourcePath: source, dest, linkType);
+ fs.symlinkSync(linkType === 'junction' ? resolvedSourcePath : source, dest, linkType);
} catch (err) {
common.error(err.message);
}
} else {
if (!fs.existsSync(source)) {
- common.error('Source file does not exist', true);
+ common.error('Source file does not exist', { continue: true });
}
try {
fs.linkSync(source, dest);
@@ -65,5 +67,6 @@ function _ln(options, source, dest) {
common.error(err.message);
}
}
+ return '';
}
module.exports = _ln;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/ls.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/ls.js b/node_modules/shelljs/src/ls.js
index 6a54b3a..bb1b6a7 100644
--- a/node_modules/shelljs/src/ls.js
+++ b/node_modules/shelljs/src/ls.js
@@ -1,8 +1,20 @@
var path = require('path');
var fs = require('fs');
var common = require('./common');
-var _cd = require('./cd');
-var _pwd = require('./pwd');
+var glob = require('glob');
+
+var globPatternRecursive = path.sep + '**';
+
+common.register('ls', _ls, {
+ cmdOptions: {
+ 'R': 'recursive',
+ 'A': 'all',
+ 'L': 'link',
+ 'a': 'all_deprecated',
+ 'd': 'directory',
+ 'l': 'long',
+ },
+});
//@
//@ ### ls([options,] [path, ...])
@@ -11,6 +23,7 @@ var _pwd = require('./pwd');
//@
//@ + `-R`: recursive
//@ + `-A`: all files (include files beginning with `.`, except for `.` and `..`)
+//@ + `-L`: follow symlinks
//@ + `-d`: list directories themselves, not their contents
//@ + `-l`: list objects representing each file, each with fields containing `ls
//@ -l` output fields. See
@@ -28,14 +41,6 @@ var _pwd = require('./pwd');
//@
//@ Returns array of files in the given path, or in current directory if no path provided.
function _ls(options, paths) {
- options = common.parseOptions(options, {
- 'R': 'recursive',
- 'A': 'all',
- 'a': 'all_deprecated',
- 'd': 'directory',
- 'l': 'long'
- });
-
if (options.all_deprecated) {
// We won't support the -a option as it's hard to image why it's useful
// (it includes '.' and '..' in addition to '.*' files)
@@ -44,125 +49,78 @@ function _ls(options, paths) {
options.all = true;
}
- if (!paths)
+ if (!paths) {
paths = ['.'];
- else if (typeof paths === 'object')
- paths = paths; // assume array
- else if (typeof paths === 'string')
+ } else {
paths = [].slice.call(arguments, 1);
+ }
var list = [];
- // Conditionally pushes file to list - returns true if pushed, false otherwise
- // (e.g. prevents hidden files to be included unless explicitly told so)
- function pushFile(file, query) {
- var name = file.name || file;
- // hidden file?
- if (path.basename(name)[0] === '.') {
- // not explicitly asking for hidden files?
- if (!options.all && !(path.basename(query)[0] === '.' && path.basename(query).length > 1))
- return false;
+ function pushFile(abs, relName, stat) {
+ if (process.platform === 'win32') {
+ relName = relName.replace(/\\/g, '/');
}
-
- if (common.platform === 'win')
- name = name.replace(/\\/g, '/');
-
- if (file.name) {
- file.name = name;
+ if (options.long) {
+ stat = stat || (options.link ? fs.statSync(abs) : fs.lstatSync(abs));
+ list.push(addLsAttributes(relName, stat));
} else {
- file = name;
+ // list.push(path.relative(rel || '.', file));
+ list.push(relName);
}
- list.push(file);
- return true;
}
- paths.forEach(function(p) {
- if (fs.existsSync(p)) {
- var stats = ls_stat(p);
- // Simple file?
- if (stats.isFile()) {
- if (options.long) {
- pushFile(stats, p);
- } else {
- pushFile(p, p);
- }
- return; // continue
- }
+ paths.forEach(function (p) {
+ var stat;
- // Simple dir?
- if (options.directory) {
- pushFile(p, p);
- return;
- } else if (stats.isDirectory()) {
- // Iterate over p contents
- fs.readdirSync(p).forEach(function(file) {
- var orig_file = file;
- if (options.long)
- file = ls_stat(path.join(p, file));
- if (!pushFile(file, p))
- return;
+ try {
+ stat = options.link ? fs.statSync(p) : fs.lstatSync(p);
+ } catch (e) {
+ common.error('no such file or directory: ' + p, 2, { continue: true });
+ return;
+ }
- // Recursive?
- if (options.recursive) {
- var oldDir = _pwd();
- _cd('', p);
- if (fs.statSync(orig_file).isDirectory())
- list = list.concat(_ls('-R'+(options.all?'A':''), orig_file+'/*'));
- _cd('', oldDir);
+ // If the stat succeeded
+ if (stat.isDirectory() && !options.directory) {
+ if (options.recursive) {
+ // use glob, because it's simple
+ glob.sync(p + globPatternRecursive, { dot: options.all, follow: options.link })
+ .forEach(function (item) {
+ // Glob pattern returns the directory itself and needs to be filtered out.
+ if (path.relative(p, item)) {
+ pushFile(item, path.relative(p, item));
+ }
+ });
+ } else if (options.all) {
+ // use fs.readdirSync, because it's fast
+ fs.readdirSync(p).forEach(function (item) {
+ pushFile(path.join(p, item), item);
+ });
+ } else {
+ // use fs.readdirSync and then filter out secret files
+ fs.readdirSync(p).forEach(function (item) {
+ if (item[0] !== '.') {
+ pushFile(path.join(p, item), item);
}
});
- return; // continue
}
+ } else {
+ pushFile(p, p, stat);
}
-
- // p does not exist - possible wildcard present
-
- var basename = path.basename(p);
- var dirname = path.dirname(p);
- // Wildcard present on an existing dir? (e.g. '/tmp/*.js')
- if (basename.search(/\*/) > -1 && fs.existsSync(dirname) && fs.statSync(dirname).isDirectory) {
- // Escape special regular expression chars
- var regexp = basename.replace(/(\^|\$|\(|\)|<|>|\[|\]|\{|\}|\.|\+|\?)/g, '\\$1');
- // Translates wildcard into regex
- regexp = '^' + regexp.replace(/\*/g, '.*') + '$';
- // Iterate over directory contents
- fs.readdirSync(dirname).forEach(function(file) {
- if (file.match(new RegExp(regexp))) {
- var file_path = path.join(dirname, file);
- file_path = options.long ? ls_stat(file_path) : file_path;
- if (file_path.name)
- file_path.name = path.normalize(file_path.name);
- else
- file_path = path.normalize(file_path);
- if (!pushFile(file_path, basename))
- return;
-
- // Recursive?
- if (options.recursive) {
- var pp = dirname + '/' + file;
- if (fs.lstatSync(pp).isDirectory())
- list = list.concat(_ls('-R'+(options.all?'A':''), pp+'/*'));
- } // recursive
- } // if file matches
- }); // forEach
- return;
- }
-
- common.error('no such file or directory: ' + p, true);
});
+ // Add methods, to make this more compatible with ShellStrings
return list;
}
-module.exports = _ls;
-
-function ls_stat(path) {
- var stats = fs.statSync(path);
+function addLsAttributes(pathName, stats) {
// Note: this object will contain more information than .toString() returns
- stats.name = path;
- stats.toString = function() {
+ stats.name = pathName;
+ stats.toString = function () {
// Return a string resembling unix's `ls -l` format
return [this.mode, this.nlink, this.uid, this.gid, this.size, this.mtime, this.name].join(' ');
};
return stats;
}
+
+module.exports = _ls;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/mkdir.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/mkdir.js b/node_modules/shelljs/src/mkdir.js
index 8b4fd99..115f75c 100644
--- a/node_modules/shelljs/src/mkdir.js
+++ b/node_modules/shelljs/src/mkdir.js
@@ -2,10 +2,23 @@ var common = require('./common');
var fs = require('fs');
var path = require('path');
+common.register('mkdir', _mkdir, {
+ cmdOptions: {
+ 'p': 'fullpath',
+ },
+});
+
// Recursively creates 'dir'
function mkdirSyncRecursive(dir) {
var baseDir = path.dirname(dir);
+ // Prevents some potential problems arising from malformed UNCs or
+ // insufficient permissions.
+ /* istanbul ignore next */
+ if (baseDir === dir) {
+ common.error('dirname() failed: [' + dir + ']');
+ }
+
// Base dir exists, no recursion necessary
if (fs.existsSync(baseDir)) {
fs.mkdirSync(dir, parseInt('0777', 8));
@@ -35,34 +48,46 @@ function mkdirSyncRecursive(dir) {
//@
//@ Creates directories.
function _mkdir(options, dirs) {
- options = common.parseOptions(options, {
- 'p': 'fullpath'
- });
- if (!dirs)
- common.error('no paths given');
+ if (!dirs) common.error('no paths given');
- if (typeof dirs === 'string')
+ if (typeof dirs === 'string') {
dirs = [].slice.call(arguments, 1);
+ }
// if it's array leave it as it is
- dirs.forEach(function(dir) {
- if (fs.existsSync(dir)) {
- if (!options.fullpath)
- common.error('path already exists: ' + dir, true);
+ dirs.forEach(function (dir) {
+ try {
+ fs.lstatSync(dir);
+ if (!options.fullpath) {
+ common.error('path already exists: ' + dir, { continue: true });
+ }
return; // skip dir
+ } catch (e) {
+ // do nothing
}
// Base dir does not exist, and no -p option given
var baseDir = path.dirname(dir);
if (!fs.existsSync(baseDir) && !options.fullpath) {
- common.error('no such file or directory: ' + baseDir, true);
+ common.error('no such file or directory: ' + baseDir, { continue: true });
return; // skip dir
}
- if (options.fullpath)
- mkdirSyncRecursive(dir);
- else
- fs.mkdirSync(dir, parseInt('0777', 8));
+ try {
+ if (options.fullpath) {
+ mkdirSyncRecursive(path.resolve(dir));
+ } else {
+ fs.mkdirSync(dir, parseInt('0777', 8));
+ }
+ } catch (e) {
+ if (e.code === 'EACCES') {
+ common.error('cannot create directory ' + dir + ': Permission denied');
+ } else {
+ /* istanbul ignore next */
+ throw e;
+ }
+ }
});
+ return '';
} // mkdir
module.exports = _mkdir;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/mv.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/mv.js b/node_modules/shelljs/src/mv.js
index 69cc03f..7fc7cf0 100644
--- a/node_modules/shelljs/src/mv.js
+++ b/node_modules/shelljs/src/mv.js
@@ -1,6 +1,15 @@
var fs = require('fs');
var path = require('path');
var common = require('./common');
+var cp = require('./cp');
+var rm = require('./rm');
+
+common.register('mv', _mv, {
+ cmdOptions: {
+ 'f': '!no_force',
+ 'n': 'no_force',
+ },
+});
//@
//@ ### mv([options ,] source [, source ...], dest')
@@ -18,13 +27,8 @@ var common = require('./common');
//@ mv(['file1', 'file2'], 'dir/'); // same as above
//@ ```
//@
-//@ Moves files. The wildcard `*` is accepted.
+//@ Moves files.
function _mv(options, sources, dest) {
- options = common.parseOptions(options, {
- 'f': '!no_force',
- 'n': 'no_force'
- });
-
// Get sources, dest
if (arguments.length < 3) {
common.error('missing <source> and/or <dest>');
@@ -33,28 +37,27 @@ function _mv(options, sources, dest) {
dest = arguments[arguments.length - 1];
} else if (typeof sources === 'string') {
sources = [sources];
- } else if ('length' in sources) {
- sources = sources; // no-op for array
} else {
+ // TODO(nate): figure out if we actually need this line
common.error('invalid arguments');
}
- sources = common.expand(sources);
-
- var exists = fs.existsSync(dest),
- stats = exists && fs.statSync(dest);
+ var exists = fs.existsSync(dest);
+ var stats = exists && fs.statSync(dest);
// Dest is not existing dir, but multiple sources given
- if ((!exists || !stats.isDirectory()) && sources.length > 1)
+ if ((!exists || !stats.isDirectory()) && sources.length > 1) {
common.error('dest is not a directory (too many sources)');
+ }
// Dest is an existing file, but no -f given
- if (exists && stats.isFile() && options.no_force)
+ if (exists && stats.isFile() && options.no_force) {
common.error('dest file already exists: ' + dest);
+ }
- sources.forEach(function(src) {
+ sources.forEach(function (src) {
if (!fs.existsSync(src)) {
- common.error('no such file or directory: '+src, true);
+ common.error('no such file or directory: ' + src, { continue: true });
return; // skip file
}
@@ -63,20 +66,34 @@ function _mv(options, sources, dest) {
// When copying to '/path/dir':
// thisDest = '/path/dir/file1'
var thisDest = dest;
- if (fs.existsSync(dest) && fs.statSync(dest).isDirectory())
+ if (fs.existsSync(dest) && fs.statSync(dest).isDirectory()) {
thisDest = path.normalize(dest + '/' + path.basename(src));
+ }
if (fs.existsSync(thisDest) && options.no_force) {
- common.error('dest file already exists: ' + thisDest, true);
+ common.error('dest file already exists: ' + thisDest, { continue: true });
return; // skip file
}
if (path.resolve(src) === path.dirname(path.resolve(thisDest))) {
- common.error('cannot move to self: '+src, true);
+ common.error('cannot move to self: ' + src, { continue: true });
return; // skip file
}
- fs.renameSync(src, thisDest);
+ try {
+ fs.renameSync(src, thisDest);
+ } catch (e) {
+ /* istanbul ignore next */
+ if (e.code === 'EXDEV') {
+ // If we're trying to `mv` to an external partition, we'll actually need
+ // to perform a copy and then clean up the original file. If either the
+ // copy or the rm fails with an exception, we should allow this
+ // exception to pass up to the top level.
+ cp('-r', src, thisDest);
+ rm('-rf', src);
+ }
+ }
}); // forEach(src)
+ return '';
} // mv
module.exports = _mv;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/popd.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/popd.js b/node_modules/shelljs/src/popd.js
index 11ea24f..d9eac3f 100644
--- a/node_modules/shelljs/src/popd.js
+++ b/node_modules/shelljs/src/popd.js
@@ -1 +1 @@
-// see dirs.js
\ No newline at end of file
+// see dirs.js
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/pushd.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/pushd.js b/node_modules/shelljs/src/pushd.js
index 11ea24f..d9eac3f 100644
--- a/node_modules/shelljs/src/pushd.js
+++ b/node_modules/shelljs/src/pushd.js
@@ -1 +1 @@
-// see dirs.js
\ No newline at end of file
+// see dirs.js
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/pwd.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/pwd.js b/node_modules/shelljs/src/pwd.js
index 26cefe0..3861851 100644
--- a/node_modules/shelljs/src/pwd.js
+++ b/node_modules/shelljs/src/pwd.js
@@ -1,11 +1,15 @@
var path = require('path');
var common = require('./common');
+common.register('pwd', _pwd, {
+ allowGlobbing: false,
+});
+
//@
//@ ### pwd()
//@ Returns the current directory.
function _pwd() {
var pwd = path.resolve(process.cwd());
- return common.ShellString(pwd);
+ return pwd;
}
module.exports = _pwd;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/rm.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/rm.js b/node_modules/shelljs/src/rm.js
index cf2e95b..5953681 100644
--- a/node_modules/shelljs/src/rm.js
+++ b/node_modules/shelljs/src/rm.js
@@ -1,6 +1,14 @@
var common = require('./common');
var fs = require('fs');
+common.register('rm', _rm, {
+ cmdOptions: {
+ 'f': 'force',
+ 'r': 'recursive',
+ 'R': 'recursive',
+ },
+});
+
// Recursively removes 'dir'
// Adapted from https://github.com/ryanmcgrath/wrench-js
//
@@ -15,32 +23,24 @@ function rmdirSyncRecursive(dir, force) {
files = fs.readdirSync(dir);
// Loop through and delete everything in the sub-tree after checking it
- for(var i = 0; i < files.length; i++) {
- var file = dir + "/" + files[i],
- currFile = fs.lstatSync(file);
+ for (var i = 0; i < files.length; i++) {
+ var file = dir + '/' + files[i];
+ var currFile = fs.lstatSync(file);
- if(currFile.isDirectory()) { // Recursive function back to the beginning
+ if (currFile.isDirectory()) { // Recursive function back to the beginning
rmdirSyncRecursive(file, force);
- }
-
- else if(currFile.isSymbolicLink()) { // Unlink symlinks
+ } else { // Assume it's a file - perhaps a try/catch belongs here?
if (force || isWriteable(file)) {
try {
common.unlinkSync(file);
} catch (e) {
- common.error('could not remove file (code '+e.code+'): ' + file, true);
+ /* istanbul ignore next */
+ common.error('could not remove file (code ' + e.code + '): ' + file, {
+ continue: true,
+ });
}
}
}
-
- else // Assume it's a file - perhaps a try/catch belongs here?
- if (force || isWriteable(file)) {
- try {
- common.unlinkSync(file);
- } catch (e) {
- common.error('could not remove file (code '+e.code+'): ' + file, true);
- }
- }
}
// Now that we know everything in the sub-tree has been deleted, we can delete the main directory.
@@ -50,16 +50,19 @@ function rmdirSyncRecursive(dir, force) {
try {
// Retry on windows, sometimes it takes a little time before all the files in the directory are gone
var start = Date.now();
- while (true) {
+
+ // TODO: replace this with a finite loop
+ for (;;) {
try {
result = fs.rmdirSync(dir);
- if (fs.existsSync(dir)) throw { code: "EAGAIN" };
+ if (fs.existsSync(dir)) throw { code: 'EAGAIN' };
break;
- } catch(er) {
+ } catch (er) {
+ /* istanbul ignore next */
// In addition to error codes, also check if the directory still exists and loop again if true
- if (process.platform === "win32" && (er.code === "ENOTEMPTY" || er.code === "EBUSY" || er.code === "EPERM" || er.code === "EAGAIN")) {
+ if (process.platform === 'win32' && (er.code === 'ENOTEMPTY' || er.code === 'EBUSY' || er.code === 'EPERM' || er.code === 'EAGAIN')) {
if (Date.now() - start > 1000) throw er;
- } else if (er.code === "ENOENT") {
+ } else if (er.code === 'ENOENT') {
// Directory did not exist, deletion was successful
break;
} else {
@@ -67,8 +70,8 @@ function rmdirSyncRecursive(dir, force) {
}
}
}
- } catch(e) {
- common.error('could not remove directory (code '+e.code+'): ' + dir, true);
+ } catch (e) {
+ common.error('could not remove directory (code ' + e.code + '): ' + dir, { continue: true });
}
return result;
@@ -81,7 +84,7 @@ function isWriteable(file) {
try {
var __fd = fs.openSync(file, 'a');
fs.closeSync(__fd);
- } catch(e) {
+ } catch (e) {
writePermission = false;
}
@@ -104,60 +107,44 @@ function isWriteable(file) {
//@ rm(['some_file.txt', 'another_file.txt']); // same as above
//@ ```
//@
-//@ Removes files. The wildcard `*` is accepted.
+//@ Removes files.
function _rm(options, files) {
- options = common.parseOptions(options, {
- 'f': 'force',
- 'r': 'recursive',
- 'R': 'recursive'
- });
- if (!files)
- common.error('no paths given');
-
- if (typeof files === 'string')
- files = [].slice.call(arguments, 1);
- // if it's array leave it as it is
+ if (!files) common.error('no paths given');
- files = common.expand(files);
+ // Convert to array
+ files = [].slice.call(arguments, 1);
- files.forEach(function(file) {
- if (!fs.existsSync(file)) {
+ files.forEach(function (file) {
+ var stats;
+ try {
+ stats = fs.lstatSync(file); // test for existence
+ } catch (e) {
// Path does not exist, no force flag given
- if (!options.force)
- common.error('no such file or directory: '+file, true);
-
+ if (!options.force) {
+ common.error('no such file or directory: ' + file, { continue: true });
+ }
return; // skip file
}
// If here, path exists
-
- var stats = fs.lstatSync(file);
- if (stats.isFile() || stats.isSymbolicLink()) {
-
- // Do not check for file writing permissions
- if (options.force) {
+ if (stats.isFile()) {
+ if (options.force || isWriteable(file)) {
+ // -f was passed, or file is writable, so it can be removed
common.unlinkSync(file);
- return;
+ } else {
+ common.error('permission denied: ' + file, { continue: true });
}
-
- if (isWriteable(file))
- common.unlinkSync(file);
- else
- common.error('permission denied: '+file, true);
-
- return;
- } // simple file
-
- // Path is an existing directory, but no -r flag given
- if (stats.isDirectory() && !options.recursive) {
- common.error('path is a directory', true);
- return; // skip path
- }
-
- // Recursively remove existing directory
- if (stats.isDirectory() && options.recursive) {
- rmdirSyncRecursive(file, options.force);
+ } else if (stats.isDirectory()) {
+ if (options.recursive) {
+ // -r was passed, so directory can be removed
+ rmdirSyncRecursive(file, options.force);
+ } else {
+ common.error('path is a directory', { continue: true });
+ }
+ } else if (stats.isSymbolicLink() || stats.isFIFO()) {
+ common.unlinkSync(file);
}
}); // forEach(file)
+ return '';
} // rm
module.exports = _rm;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/sed.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/sed.js b/node_modules/shelljs/src/sed.js
index baa385b..dfdc0a7 100644
--- a/node_modules/shelljs/src/sed.js
+++ b/node_modules/shelljs/src/sed.js
@@ -1,6 +1,14 @@
var common = require('./common');
var fs = require('fs');
+common.register('sed', _sed, {
+ globStart: 3, // don't glob-expand regexes
+ canReceivePipe: true,
+ cmdOptions: {
+ 'i': 'inplace',
+ },
+});
+
//@
//@ ### sed([options,] search_regex, replacement, file [, file ...])
//@ ### sed([options,] search_regex, replacement, file_array)
@@ -17,48 +25,62 @@ var fs = require('fs');
//@
//@ Reads an input string from `files` and performs a JavaScript `replace()` on the input
//@ using the given search regex and replacement string or function. Returns the new string after replacement.
+//@
+//@ Note:
+//@
+//@ Like unix `sed`, ShellJS `sed` supports capture groups. Capture groups are specified
+//@ using the `$n` syntax:
+//@
+//@ ```javascript
+//@ sed(/(\w+)\s(\w+)/, '$2, $1', 'file.txt');
+//@ ```
function _sed(options, regex, replacement, files) {
- options = common.parseOptions(options, {
- 'i': 'inplace'
- });
+ // Check if this is coming from a pipe
+ var pipe = common.readFromPipe();
- if (typeof replacement === 'string' || typeof replacement === 'function')
- replacement = replacement; // no-op
- else if (typeof replacement === 'number')
- replacement = replacement.toString(); // fallback
- else
- common.error('invalid replacement string');
+ if (typeof replacement !== 'string' && typeof replacement !== 'function') {
+ if (typeof replacement === 'number') {
+ replacement = replacement.toString(); // fallback
+ } else {
+ common.error('invalid replacement string');
+ }
+ }
// Convert all search strings to RegExp
- if (typeof regex === 'string')
+ if (typeof regex === 'string') {
regex = RegExp(regex);
+ }
- if (!files)
+ if (!files && !pipe) {
common.error('no files given');
+ }
- if (typeof files === 'string')
- files = [].slice.call(arguments, 3);
- // if it's array leave it as it is
+ files = [].slice.call(arguments, 3);
- files = common.expand(files);
+ if (pipe) {
+ files.unshift('-');
+ }
var sed = [];
- files.forEach(function(file) {
- if (!fs.existsSync(file)) {
- common.error('no such file or directory: ' + file, true);
+ files.forEach(function (file) {
+ if (!fs.existsSync(file) && file !== '-') {
+ common.error('no such file or directory: ' + file, 2, { continue: true });
return;
}
- var result = fs.readFileSync(file, 'utf8').split('\n').map(function (line) {
+ var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8');
+ var lines = contents.split(/\r*\n/);
+ var result = lines.map(function (line) {
return line.replace(regex, replacement);
}).join('\n');
sed.push(result);
- if (options.inplace)
+ if (options.inplace) {
fs.writeFileSync(file, result, 'utf8');
+ }
});
- return common.ShellString(sed.join('\n'));
+ return sed.join('\n');
}
module.exports = _sed;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[07/25] cordova-browser git commit: skip pre-promise node versions
Posted by pu...@apache.org.
skip pre-promise node versions
Project: http://git-wip-us.apache.org/repos/asf/cordova-browser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-browser/commit/7d48b143
Tree: http://git-wip-us.apache.org/repos/asf/cordova-browser/tree/7d48b143
Diff: http://git-wip-us.apache.org/repos/asf/cordova-browser/diff/7d48b143
Branch: refs/heads/master
Commit: 7d48b143bddbb9b124ca0e36edc6580db7be0a10
Parents: 6dd8c6d
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu Apr 13 00:22:18 2017 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu Apr 13 00:22:18 2017 -0700
----------------------------------------------------------------------
.travis.yml | 2 --
appveyor.yml | 2 --
2 files changed, 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/7d48b143/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index d9c6cdd..73ccdf6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,8 +1,6 @@
language: node_js
sudo: false
node_js:
- - "0.10"
- - "0.12"
- "4"
- "6"
install:
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/7d48b143/appveyor.yml
----------------------------------------------------------------------
diff --git a/appveyor.yml b/appveyor.yml
index 8ce94b7..7e9a925 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -22,8 +22,6 @@
environment:
matrix:
- - nodejs_version: "0.10"
- - nodejs_version: "0.12"
- nodejs_version: "4"
- nodejs_version: "6"
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[21/25] cordova-browser git commit: cleaned up merge
Posted by pu...@apache.org.
cleaned up merge
Project: http://git-wip-us.apache.org/repos/asf/cordova-browser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-browser/commit/9a341aa3
Tree: http://git-wip-us.apache.org/repos/asf/cordova-browser/tree/9a341aa3
Diff: http://git-wip-us.apache.org/repos/asf/cordova-browser/diff/9a341aa3
Branch: refs/heads/master
Commit: 9a341aa3bb6dc221bd5f86321de0ba3f3a972a23
Parents: d5fcd3f 84dbb72
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu May 25 12:56:15 2017 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu May 25 12:56:15 2017 -0700
----------------------------------------------------------------------
package.json | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/9a341aa3/package.json
----------------------------------------------------------------------
diff --cc package.json
index 26fbc59,5af61de..a7ce43c
--- a/package.json
+++ b/package.json
@@@ -1,57 -1,54 +1,60 @@@
{
- "name": "cordova-browser",
- "version": "4.2.0-dev",
- "description": "cordova-browser release",
- "main": "bin/create",
- "repository": {
- "type": "git",
- "url": "https://git-wip-us.apache.org/repos/asf/cordova-browser.git"
+ "name": "cordova-browser",
+ "version": "4.2.0-dev",
+ "description": "cordova-browser release",
+ "main": "bin/template/cordova/Api.js",
+ "bin": "bin/create",
+ "repository": {
+ "type": "git",
+ "url": "https://git-wip-us.apache.org/repos/asf/cordova-browser.git"
+ },
++ "bugs": {
++ "url": "https://issues.apache.org/jira/browse/CB"
++ },
+ "keywords": [
+ "cordova",
+ "browser",
+ "apache"
+ ],
+ "scripts": {
+ "jshint": "jshint bin && jshint spec",
+ "jasmine": "jasmine --captureExceptions --color",
+ "test": "npm run jshint && npm run jasmine"
+ },
+ "dependencies": {
+ "adm-zip": "^0.4.7",
+ "cordova-common": "^2.0.1",
+ "cordova-serve": "^1.0.0",
+ "nopt": "^3.0.6",
+ "q": "^1.4.1",
+ "shelljs": "^0.5.3"
+ },
+ "devDependencies": {
+ "jasmine": "^2.5.3",
+ "jshint": "^2.6.0",
+ "tmp": "^0.0.26"
+ },
+ "bundledDependencies": [
+ "adm-zip",
+ "cordova-serve",
+ "nopt",
+ "q",
+ "shelljs"
+ ],
+ "author": "Apache Software Foundation",
+ "contributors": [
+ {
+ "name": "Steve Gill",
+ "email": "steveng@adobe.com"
},
- "bugs": {
- "url": "https://issues.apache.org/jira/browse/CB"
+ {
+ "name": "Suraj Pindoria",
+ "email": "spindori@adobe.com"
},
- "keywords": [
- "cordova",
- "browser",
- "apache"
- ],
- "scripts": {
- "test": "npm run jshint && npm run test-unit",
- "test-unit": "node node_modules/jasmine-node/lib/jasmine-node/cli.js --captureExceptions tests/spec/",
- "jshint": "node node_modules/jshint/bin/jshint bin && node node_modules/jshint/bin/jshint tests"
- },
- "dependencies": {
- "adm-zip": "^0.4.7",
- "cordova-serve": "^1.0.0",
- "nopt": "^3.0.6",
- "q": "^1.4.1",
- "shelljs": "^0.6.0"
- },
- "devDependencies": {
- "jasmine-node": "~1",
- "jshint": "^2.6.0",
- "tmp": "^0.0.26"
- },
- "bundledDependencies": [
- "adm-zip",
- "cordova-serve",
- "nopt",
- "q",
- "shelljs"
- ],
- "author": "Apache Software Foundation",
- "contributors": [
- {
- "name": "Steve Gill",
- "email": "steveng@adobe.com"
- },
- {
- "name": "Suraj Pindoria",
- "email": "spindori@adobe.com"
- }
- ],
- "license": "Apache-2.0"
+ {
+ "name": "Jesse MacFadyen",
+ "email": "purplecabbage@apache.org"
+ }
+ ],
+ "license": "Apache-2.0"
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[06/25] cordova-browser git commit: fix failing tests
Posted by pu...@apache.org.
fix failing tests
Project: http://git-wip-us.apache.org/repos/asf/cordova-browser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-browser/commit/6dd8c6dd
Tree: http://git-wip-us.apache.org/repos/asf/cordova-browser/tree/6dd8c6dd
Diff: http://git-wip-us.apache.org/repos/asf/cordova-browser/diff/6dd8c6dd
Branch: refs/heads/master
Commit: 6dd8c6dd7c222943f926ed4f4debeb591c05be28
Parents: ea7fdc4
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu Apr 13 00:18:06 2017 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu Apr 13 00:19:09 2017 -0700
----------------------------------------------------------------------
bin/template/cordova/Api.js | 13 +++++++++----
bin/template/cordova/lib/clean.js | 7 ++-----
bin/template/cordova/lib/run.js | 2 +-
3 files changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/6dd8c6dd/bin/template/cordova/Api.js
----------------------------------------------------------------------
diff --git a/bin/template/cordova/Api.js b/bin/template/cordova/Api.js
index 80f79ff..4a75745 100644
--- a/bin/template/cordova/Api.js
+++ b/bin/template/cordova/Api.js
@@ -49,16 +49,21 @@ function Api(platform, platformRootDir, events) {
Api.createPlatform = function (dest, config, options, events) {
- console.log("browser createPlatform !! dest:" + dest);
+ //console.log("browser createPlatform !! dest:" + dest);
events = setupEvents(events);
- var name = config.name();
+ var name = "HelloCordova";
+ var id = "io.cordova.hellocordova";
+ if(config) {
+ name = config.name();
+ id = config.packageName();
+ }
var result;
try {
var creator = require('../../lib/create');
- console.log("creator = " + creator);
- result = creator.createProject(dest, config.packageName(), name, options)
+ // console.log("creator = " + creator);
+ result = creator.createProject(dest, id, name, options)
.then(function () {
// after platform is created we return Api instance based on new Api.js location
// This is required to correctly resolve paths in the future api calls
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/6dd8c6dd/bin/template/cordova/lib/clean.js
----------------------------------------------------------------------
diff --git a/bin/template/cordova/lib/clean.js b/bin/template/cordova/lib/clean.js
index dff4c06..4175a92 100644
--- a/bin/template/cordova/lib/clean.js
+++ b/bin/template/cordova/lib/clean.js
@@ -27,15 +27,13 @@ var fs = require('fs'),
var run = function(){
- console.log("cleaning ... ");
+ // TODO: everything calls check_reqs ... why?
// Check that requirements are (still) met
if (!check_reqs.run()) {
console.error('Please make sure you meet the software requirements in order to clean an browser cordova project');
process.exit(2);
}
- console.log('Cleaning Browser project');
-
try {
if (fs.existsSync(platformBuildDir)) {
shell.rm('-r', platformBuildDir);
@@ -51,5 +49,4 @@ module.exports.run = run;
module.exports.cleanProject = function(){
console.log("lib/clean will soon only export a `run` command, please update to not call `cleanProject`.");
return run();
-}
-
+};
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/6dd8c6dd/bin/template/cordova/lib/run.js
----------------------------------------------------------------------
diff --git a/bin/template/cordova/lib/run.js b/bin/template/cordova/lib/run.js
index 083178f..cf0b4e4 100644
--- a/bin/template/cordova/lib/run.js
+++ b/bin/template/cordova/lib/run.js
@@ -45,7 +45,7 @@ module.exports.run = function(args) {
server.servePlatform('browser', {port: args.port, noServerInfo: true})
.then(function () {
- if(startPage == null) {
+ if(!startPage) {
startPage = 'index.html';
}
else {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[11/25] cordova-browser git commit: update shelljs version,
prepare is working
Posted by pu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/set.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/set.js b/node_modules/shelljs/src/set.js
index 19e26d9..238e23e 100644
--- a/node_modules/shelljs/src/set.js
+++ b/node_modules/shelljs/src/set.js
@@ -1,11 +1,17 @@
var common = require('./common');
+common.register('set', _set, {
+ allowGlobbing: false,
+ wrapOutput: false,
+});
+
//@
//@ ### set(options)
//@ Available options:
//@
//@ + `+/-e`: exit upon error (`config.fatal`)
//@ + `+/-v`: verbose: show all commands (`config.verbose`)
+//@ + `+/-f`: disable filename expansion (globbing)
//@
//@ Examples:
//@
@@ -18,8 +24,7 @@ var common = require('./common');
function _set(options) {
if (!options) {
var args = [].slice.call(arguments, 0);
- if (args.length < 2)
- common.error('must provide an argument');
+ if (args.length < 2) common.error('must provide an argument');
options = args[1];
}
var negate = (options[0] === '+');
@@ -28,22 +33,23 @@ function _set(options) {
}
options = common.parseOptions(options, {
'e': 'fatal',
- 'v': 'verbose'
+ 'v': 'verbose',
+ 'f': 'noglob',
});
- var key;
if (negate) {
- for (key in options)
+ Object.keys(options).forEach(function (key) {
options[key] = !options[key];
+ });
}
- for (key in options) {
+ Object.keys(options).forEach(function (key) {
// Only change the global config if `negate` is false and the option is true
// or if `negate` is true and the option is false (aka negate !== option)
if (negate !== options[key]) {
common.config[key] = options[key];
}
- }
+ });
return;
}
module.exports = _set;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/tempdir.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/tempdir.js b/node_modules/shelljs/src/tempdir.js
index 79b949f..a2d15be 100644
--- a/node_modules/shelljs/src/tempdir.js
+++ b/node_modules/shelljs/src/tempdir.js
@@ -2,20 +2,24 @@ var common = require('./common');
var os = require('os');
var fs = require('fs');
+common.register('tempdir', _tempDir, {
+ allowGlobbing: false,
+ wrapOutput: false,
+});
+
// Returns false if 'dir' is not a writeable directory, 'dir' otherwise
function writeableDir(dir) {
- if (!dir || !fs.existsSync(dir))
- return false;
+ if (!dir || !fs.existsSync(dir)) return false;
- if (!fs.statSync(dir).isDirectory())
- return false;
+ if (!fs.statSync(dir).isDirectory()) return false;
- var testFile = dir+'/'+common.randomFileName();
+ var testFile = dir + '/' + common.randomFileName();
try {
fs.writeFileSync(testFile, ' ');
common.unlinkSync(testFile);
return dir;
} catch (e) {
+ /* istanbul ignore next */
return false;
}
}
@@ -34,15 +38,14 @@ function writeableDir(dir) {
//@ Follows Python's [tempfile algorithm](http://docs.python.org/library/tempfile.html#tempfile.tempdir).
function _tempDir() {
var state = common.state;
- if (state.tempDir)
- return state.tempDir; // from cache
+ if (state.tempDir) return state.tempDir; // from cache
state.tempDir = writeableDir(os.tmpdir && os.tmpdir()) || // node 0.10+
writeableDir(os.tmpDir && os.tmpDir()) || // node 0.8+
- writeableDir(process.env['TMPDIR']) ||
- writeableDir(process.env['TEMP']) ||
- writeableDir(process.env['TMP']) ||
- writeableDir(process.env['Wimp$ScrapDir']) || // RiscOS
+ writeableDir(process.env.TMPDIR) ||
+ writeableDir(process.env.TEMP) ||
+ writeableDir(process.env.TMP) ||
+ writeableDir(process.env.Wimp$ScrapDir) || // RiscOS
writeableDir('C:\\TEMP') || // Windows
writeableDir('C:\\TMP') || // Windows
writeableDir('\\TEMP') || // Windows
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/test.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/test.js b/node_modules/shelljs/src/test.js
index 068a1ce..d3d9c07 100644
--- a/node_modules/shelljs/src/test.js
+++ b/node_modules/shelljs/src/test.js
@@ -1,6 +1,22 @@
var common = require('./common');
var fs = require('fs');
+common.register('test', _test, {
+ cmdOptions: {
+ 'b': 'block',
+ 'c': 'character',
+ 'd': 'directory',
+ 'e': 'exists',
+ 'f': 'file',
+ 'L': 'link',
+ 'p': 'pipe',
+ 'S': 'socket',
+ },
+ wrapOutput: false,
+ allowGlobbing: false,
+});
+
+
//@
//@ ### test(expression)
//@ Available expression primaries:
@@ -23,63 +39,46 @@ var fs = require('fs');
//@
//@ Evaluates expression using the available primaries and returns corresponding value.
function _test(options, path) {
- if (!path)
- common.error('no path given');
-
- // hack - only works with unary primaries
- options = common.parseOptions(options, {
- 'b': 'block',
- 'c': 'character',
- 'd': 'directory',
- 'e': 'exists',
- 'f': 'file',
- 'L': 'link',
- 'p': 'pipe',
- 'S': 'socket'
- });
+ if (!path) common.error('no path given');
var canInterpret = false;
- for (var key in options)
+ Object.keys(options).forEach(function (key) {
if (options[key] === true) {
canInterpret = true;
- break;
}
+ });
- if (!canInterpret)
- common.error('could not interpret expression');
+ if (!canInterpret) common.error('could not interpret expression');
if (options.link) {
try {
return fs.lstatSync(path).isSymbolicLink();
- } catch(e) {
+ } catch (e) {
return false;
}
}
- if (!fs.existsSync(path))
- return false;
+ if (!fs.existsSync(path)) return false;
- if (options.exists)
- return true;
+ if (options.exists) return true;
var stats = fs.statSync(path);
- if (options.block)
- return stats.isBlockDevice();
+ if (options.block) return stats.isBlockDevice();
+
+ if (options.character) return stats.isCharacterDevice();
- if (options.character)
- return stats.isCharacterDevice();
+ if (options.directory) return stats.isDirectory();
- if (options.directory)
- return stats.isDirectory();
+ if (options.file) return stats.isFile();
- if (options.file)
- return stats.isFile();
+ /* istanbul ignore next */
+ if (options.pipe) return stats.isFIFO();
- if (options.pipe)
- return stats.isFIFO();
+ /* istanbul ignore next */
+ if (options.socket) return stats.isSocket();
- if (options.socket)
- return stats.isSocket();
+ /* istanbul ignore next */
+ return false; // fallback
} // test
module.exports = _test;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/to.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/to.js b/node_modules/shelljs/src/to.js
index 65d6d54..d3d9e37 100644
--- a/node_modules/shelljs/src/to.js
+++ b/node_modules/shelljs/src/to.js
@@ -2,8 +2,13 @@ var common = require('./common');
var fs = require('fs');
var path = require('path');
+common.register('to', _to, {
+ pipeOnly: true,
+ wrapOutput: false,
+});
+
//@
-//@ ### 'string'.to(file)
+//@ ### ShellString.prototype.to(file)
//@
//@ Examples:
//@
@@ -11,20 +16,22 @@ var path = require('path');
//@ cat('input.txt').to('output.txt');
//@ ```
//@
-//@ Analogous to the redirection operator `>` in Unix, but works with JavaScript strings (such as
-//@ those returned by `cat`, `grep`, etc). _Like Unix redirections, `to()` will overwrite any existing file!_
+//@ Analogous to the redirection operator `>` in Unix, but works with
+//@ ShellStrings (such as those returned by `cat`, `grep`, etc). _Like Unix
+//@ redirections, `to()` will overwrite any existing file!_
function _to(options, file) {
- if (!file)
- common.error('wrong arguments');
+ if (!file) common.error('wrong arguments');
- if (!fs.existsSync( path.dirname(file) ))
- common.error('no such file or directory: ' + path.dirname(file));
+ if (!fs.existsSync(path.dirname(file))) {
+ common.error('no such file or directory: ' + path.dirname(file));
+ }
try {
- fs.writeFileSync(file, this.toString(), 'utf8');
+ fs.writeFileSync(file, this.stdout || this.toString(), 'utf8');
return this;
- } catch(e) {
- common.error('could not write to file (code '+e.code+'): '+file, true);
+ } catch (e) {
+ /* istanbul ignore next */
+ common.error('could not write to file (code ' + e.code + '): ' + file, { continue: true });
}
}
module.exports = _to;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/toEnd.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/toEnd.js b/node_modules/shelljs/src/toEnd.js
index bf29a65..dc165fe 100644
--- a/node_modules/shelljs/src/toEnd.js
+++ b/node_modules/shelljs/src/toEnd.js
@@ -2,8 +2,13 @@ var common = require('./common');
var fs = require('fs');
var path = require('path');
+common.register('toEnd', _toEnd, {
+ pipeOnly: true,
+ wrapOutput: false,
+});
+
//@
-//@ ### 'string'.toEnd(file)
+//@ ### ShellString.prototype.toEnd(file)
//@
//@ Examples:
//@
@@ -11,20 +16,21 @@ var path = require('path');
//@ cat('input.txt').toEnd('output.txt');
//@ ```
//@
-//@ Analogous to the redirect-and-append operator `>>` in Unix, but works with JavaScript strings (such as
-//@ those returned by `cat`, `grep`, etc).
+//@ Analogous to the redirect-and-append operator `>>` in Unix, but works with
+//@ ShellStrings (such as those returned by `cat`, `grep`, etc).
function _toEnd(options, file) {
- if (!file)
- common.error('wrong arguments');
+ if (!file) common.error('wrong arguments');
- if (!fs.existsSync( path.dirname(file) ))
- common.error('no such file or directory: ' + path.dirname(file));
+ if (!fs.existsSync(path.dirname(file))) {
+ common.error('no such file or directory: ' + path.dirname(file));
+ }
try {
- fs.appendFileSync(file, this.toString(), 'utf8');
+ fs.appendFileSync(file, this.stdout || this.toString(), 'utf8');
return this;
- } catch(e) {
- common.error('could not append to file (code '+e.code+'): '+file, true);
+ } catch (e) {
+ /* istanbul ignore next */
+ common.error('could not append to file (code ' + e.code + '): ' + file, { continue: true });
}
}
module.exports = _toEnd;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/touch.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/touch.js b/node_modules/shelljs/src/touch.js
index bbc2c19..b672b2d 100644
--- a/node_modules/shelljs/src/touch.js
+++ b/node_modules/shelljs/src/touch.js
@@ -1,8 +1,19 @@
var common = require('./common');
var fs = require('fs');
+common.register('touch', _touch, {
+ cmdOptions: {
+ 'a': 'atime_only',
+ 'c': 'no_create',
+ 'd': 'date',
+ 'm': 'mtime_only',
+ 'r': 'reference',
+ },
+});
+
//@
-//@ ### touch([options,] file)
+//@ ### touch([options,] file [, file ...])
+//@ ### touch([options,] file_array)
//@ Available options:
//@
//@ + `-a`: Change only the access time
@@ -23,28 +34,18 @@ var fs = require('fs');
//@ A FILE argument that does not exist is created empty, unless -c is supplied.
//@ This is a partial implementation of *[touch(1)](http://linux.die.net/man/1/touch)*.
function _touch(opts, files) {
- opts = common.parseOptions(opts, {
- 'a': 'atime_only',
- 'c': 'no_create',
- 'd': 'date',
- 'm': 'mtime_only',
- 'r': 'reference',
- });
-
if (!files) {
- common.error('no paths given');
- }
-
- if (Array.isArray(files)) {
- files.forEach(function(f) {
- touchFile(opts, f);
- });
+ common.error('no files given');
} else if (typeof files === 'string') {
- touchFile(opts, files);
+ files = [].slice.call(arguments, 1);
} else {
common.error('file arg should be a string file path or an Array of string file paths');
}
+ files.forEach(function (f) {
+ touchFile(opts, f);
+ });
+ return '';
}
function touchFile(opts, file) {
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/src/which.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/which.js b/node_modules/shelljs/src/which.js
index d17634e..03db57b 100644
--- a/node_modules/shelljs/src/which.js
+++ b/node_modules/shelljs/src/which.js
@@ -2,23 +2,24 @@ var common = require('./common');
var fs = require('fs');
var path = require('path');
+common.register('which', _which, {
+ allowGlobbing: false,
+ cmdOptions: {
+ 'a': 'all',
+ },
+});
+
// XP's system default value for PATHEXT system variable, just in case it's not
// set on Windows.
var XP_DEFAULT_PATHEXT = '.com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh';
// Cross-platform method for splitting environment PATH variables
function splitPath(p) {
- if (!p)
- return [];
-
- if (common.platform === 'win')
- return p.split(';');
- else
- return p.split(':');
+ return p ? p.split(path.delimiter) : [];
}
-function checkPath(path) {
- return fs.existsSync(path) && !fs.statSync(path).isDirectory();
+function checkPath(pathName) {
+ return fs.existsSync(pathName) && !fs.statSync(pathName).isDirectory();
}
//@
@@ -34,65 +35,64 @@ function checkPath(path) {
//@ `PATHEXT` variable to append the extension if it's not already executable.
//@ Returns string containing the absolute path to the command.
function _which(options, cmd) {
- if (!cmd)
- common.error('must specify command');
+ if (!cmd) common.error('must specify command');
- var pathEnv = process.env.path || process.env.Path || process.env.PATH,
- pathArray = splitPath(pathEnv),
- where = null;
+ var pathEnv = process.env.path || process.env.Path || process.env.PATH;
+ var pathArray = splitPath(pathEnv);
+
+ var queryMatches = [];
// No relative/absolute paths provided?
- if (cmd.search(/\//) === -1) {
+ if (cmd.indexOf('/') === -1) {
+ // Assume that there are no extensions to append to queries (this is the
+ // case for unix)
+ var pathExtArray = [''];
+ if (common.platform === 'win') {
+ // In case the PATHEXT variable is somehow not set (e.g.
+ // child_process.spawn with an empty environment), use the XP default.
+ var pathExtEnv = process.env.PATHEXT || XP_DEFAULT_PATHEXT;
+ pathExtArray = splitPath(pathExtEnv.toUpperCase());
+ }
+
// Search for command in PATH
- pathArray.forEach(function(dir) {
- if (where)
- return; // already found it
+ for (var k = 0; k < pathArray.length; k++) {
+ // already found it
+ if (queryMatches.length > 0 && !options.all) break;
- var attempt = path.resolve(dir, cmd);
+ var attempt = path.resolve(pathArray[k], cmd);
if (common.platform === 'win') {
attempt = attempt.toUpperCase();
+ }
- // In case the PATHEXT variable is somehow not set (e.g.
- // child_process.spawn with an empty environment), use the XP default.
- var pathExtEnv = process.env.PATHEXT || XP_DEFAULT_PATHEXT;
- var pathExtArray = splitPath(pathExtEnv.toUpperCase());
- var i;
-
- // If the extension is already in PATHEXT, just return that.
- for (i = 0; i < pathExtArray.length; i++) {
- var ext = pathExtArray[i];
- if (attempt.slice(-ext.length) === ext && checkPath(attempt)) {
- where = attempt;
- return;
- }
+ var match = attempt.match(/\.[^<>:"/\|?*.]+$/);
+ if (match && pathExtArray.indexOf(match[0]) >= 0) { // this is Windows-only
+ // The user typed a query with the file extension, like
+ // `which('node.exe')`
+ if (checkPath(attempt)) {
+ queryMatches.push(attempt);
+ break;
}
-
- // Cycle through the PATHEXT variable
- var baseAttempt = attempt;
- for (i = 0; i < pathExtArray.length; i++) {
- attempt = baseAttempt + pathExtArray[i];
- if (checkPath(attempt)) {
- where = attempt;
- return;
+ } else { // All-platforms
+ // Cycle through the PATHEXT array, and check each extension
+ // Note: the array is always [''] on Unix
+ for (var i = 0; i < pathExtArray.length; i++) {
+ var ext = pathExtArray[i];
+ var newAttempt = attempt + ext;
+ if (checkPath(newAttempt)) {
+ queryMatches.push(newAttempt);
+ break;
}
}
- } else {
- // Assume it's Unix-like
- if (checkPath(attempt)) {
- where = attempt;
- return;
- }
}
- });
+ }
+ } else if (checkPath(cmd)) { // a valid absolute or relative path
+ queryMatches.push(path.resolve(cmd));
}
- // Command not found anywhere?
- if (!checkPath(cmd) && !where)
- return null;
-
- where = where || path.resolve(cmd);
-
- return common.ShellString(where);
+ if (queryMatches.length > 0) {
+ return options.all ? queryMatches : queryMatches[0];
+ }
+ return options.all ? [] : null;
}
module.exports = _which;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 76b3f70..5974095 100644
--- a/package.json
+++ b/package.json
@@ -24,7 +24,7 @@
"cordova-serve": "^1.0.0",
"nopt": "^3.0.6",
"q": "^1.4.1",
- "shelljs": "^0.6.0"
+ "shelljs": "^0.7.7"
},
"devDependencies": {
"jasmine": "^2.5.3",
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[19/25] cordova-browser git commit: back to a sane version of shelljs
Posted by pu...@apache.org.
back to a sane version of shelljs
Project: http://git-wip-us.apache.org/repos/asf/cordova-browser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-browser/commit/098fc65a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-browser/tree/098fc65a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-browser/diff/098fc65a
Branch: refs/heads/master
Commit: 098fc65ad5eda3294ec813c35be6edc997f5b036
Parents: 62e0b06
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Fri May 5 01:08:12 2017 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Fri May 5 01:08:12 2017 -0700
----------------------------------------------------------------------
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/098fc65a/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 5974095..26fbc59 100644
--- a/package.json
+++ b/package.json
@@ -24,7 +24,7 @@
"cordova-serve": "^1.0.0",
"nopt": "^3.0.6",
"q": "^1.4.1",
- "shelljs": "^0.7.7"
+ "shelljs": "^0.5.3"
},
"devDependencies": {
"jasmine": "^2.5.3",
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[02/25] cordova-browser git commit: added some basic tests,
and updated package with Jasmine@2.5.3
Posted by pu...@apache.org.
added some basic tests, and updated package with Jasmine@2.5.3
Project: http://git-wip-us.apache.org/repos/asf/cordova-browser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-browser/commit/44578d2f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-browser/tree/44578d2f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-browser/diff/44578d2f
Branch: refs/heads/master
Commit: 44578d2f9399dd614b270ce98ce00ed7db4d137c
Parents: f1b136d
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Fri Apr 7 14:59:52 2017 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Fri Apr 7 14:59:52 2017 -0700
----------------------------------------------------------------------
package.json | 101 +++++++++++++++++-----------------
spec/create.spec.js | 119 +++++++++++++++++++++++++++++++++++++++++
spec/projectApi.spec.js | 116 +++++++++++++++++++++++++++++++++++++++
spec/support/jasmine.json | 10 ++++
4 files changed, 298 insertions(+), 48 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/44578d2f/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 3daf7d4..8a2b4ed 100644
--- a/package.json
+++ b/package.json
@@ -1,51 +1,56 @@
{
- "name": "cordova-browser",
- "version": "4.2.0-dev",
- "description": "cordova-browser release",
- "main": "bin/create",
- "repository": {
- "type": "git",
- "url": "https://git-wip-us.apache.org/repos/asf/cordova-browser.git"
+ "name": "cordova-browser",
+ "version": "4.2.0-dev",
+ "description": "cordova-browser release",
+ "main": "bin/create",
+ "repository": {
+ "type": "git",
+ "url": "https://git-wip-us.apache.org/repos/asf/cordova-browser.git"
+ },
+ "keywords": [
+ "cordova",
+ "browser",
+ "apache"
+ ],
+ "scripts": {
+ "jshint": "jshint bin && jshint spec",
+ "jasmine": "jasmine --captureExceptions --color",
+ "test": "npm run jshint && npm run jasmine"
+ },
+ "dependencies": {
+ "adm-zip": "^0.4.7",
+ "cordova-common": "^2.0.1",
+ "cordova-serve": "^1.0.0",
+ "nopt": "^3.0.6",
+ "q": "^1.4.1",
+ "shelljs": "^0.6.0"
+ },
+ "devDependencies": {
+ "jasmine": "^2.5.3",
+ "jshint": "^2.6.0",
+ "tmp": "^0.0.26"
+ },
+ "bundledDependencies": [
+ "adm-zip",
+ "cordova-serve",
+ "nopt",
+ "q",
+ "shelljs"
+ ],
+ "author": "Apache Software Foundation",
+ "contributors": [
+ {
+ "name": "Steve Gill",
+ "email": "steveng@adobe.com"
},
- "keywords": [
- "cordova",
- "browser",
- "apache"
- ],
- "scripts": {
- "test": "npm run jshint && npm run test-unit",
- "test-unit": "node node_modules/jasmine-node/lib/jasmine-node/cli.js --captureExceptions tests/spec/",
- "jshint": "node node_modules/jshint/bin/jshint bin && node node_modules/jshint/bin/jshint tests"
+ {
+ "name": "Suraj Pindoria",
+ "email": "spindori@adobe.com"
},
- "dependencies": {
- "adm-zip": "^0.4.7",
- "cordova-serve": "^1.0.0",
- "nopt": "^3.0.6",
- "q": "^1.4.1",
- "shelljs": "^0.6.0"
- },
- "devDependencies": {
- "jasmine-node": "~1",
- "jshint": "^2.6.0",
- "tmp": "^0.0.26"
- },
- "bundledDependencies": [
- "adm-zip",
- "cordova-serve",
- "nopt",
- "q",
- "shelljs"
- ],
- "author": "Apache Software Foundation",
- "contributors": [
- {
- "name": "Steve Gill",
- "email": "steveng@adobe.com"
- },
- {
- "name": "Suraj Pindoria",
- "email": "spindori@adobe.com"
- }
- ],
- "license": "Apache-2.0"
-}
\ No newline at end of file
+ {
+ "name": "Jesse MacFadyen",
+ "email": "purplecabbage@apache.org"
+ }
+ ],
+ "license": "Apache-2.0"
+}
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/44578d2f/spec/create.spec.js
----------------------------------------------------------------------
diff --git a/spec/create.spec.js b/spec/create.spec.js
new file mode 100644
index 0000000..b920417
--- /dev/null
+++ b/spec/create.spec.js
@@ -0,0 +1,119 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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 shell = require('shelljs');
+var fs = require('fs');
+var path = require('path');
+var util = require('util');
+
+var cordova_bin = path.join(__dirname, '../bin');// is this the same on all platforms?
+var tmpDir = path.join(__dirname, '../temp');
+var createScriptPath = path.join(cordova_bin,'create');
+
+function createAndBuild(projectname, projectid) {
+
+ var return_code = 0;
+ var command;
+
+ // remove existing folder
+ shell.rm('-rf', tmpDir);
+ shell.mkdir(tmpDir);
+
+ // create the project
+ command = util.format('"%s" "%s/%s" "%s" "%s"', createScriptPath, tmpDir, projectname, projectid, projectname);
+ //shell.echo(command);
+ return_code = shell.exec(command).code;
+ expect(return_code).toBe(0);
+
+
+ var tempCordovaScriptsPath = path.join(tmpDir,projectname,"cordova");
+
+ console.log("tempCordovaScriptsPath = " + tempCordovaScriptsPath);
+
+ // created project has scripts in the cordova folder
+ // build, clean, log, run, version
+ expect(fs.existsSync(path.join(tempCordovaScriptsPath,'build'))).toBe(true);
+ expect(fs.existsSync(path.join(tempCordovaScriptsPath,'clean'))).toBe(true);
+ expect(fs.existsSync(path.join(tempCordovaScriptsPath,'log'))).toBe(true);
+ expect(fs.existsSync(path.join(tempCordovaScriptsPath,'run'))).toBe(true);
+ expect(fs.existsSync(path.join(tempCordovaScriptsPath,'version'))).toBe(true);
+
+
+ // // build the project
+ command = util.format('"%s/cordova/build"', path.join(tmpDir, projectname));
+ //shell.echo(command);
+ return_code = shell.exec(command, { silent: true }).code;
+ expect(return_code).toBe(0);
+
+ // clean-up
+ shell.rm('-rf', tmpDir);
+}
+
+
+describe('create', function() {
+
+ it('has a create script in bin/cordova',function(){
+ expect(fs.existsSync(createScriptPath)).toBe(true);
+ });
+
+
+ it('create project with ascii name, no spaces', function() {
+ var projectname = 'testcreate';
+ var projectid = 'com.test.app1';
+
+ createAndBuild(projectname, projectid);
+ });
+
+ it('create project with ascii name, and spaces', function() {
+ var projectname = 'test create';
+ var projectid = 'com.test.app2';
+
+ createAndBuild(projectname, projectid);
+ });
+
+ it('create project with unicode name, no spaces', function() {
+ var projectname = '応応応応用用用用';
+ var projectid = 'com.test.app3';
+
+ createAndBuild(projectname, projectid);
+ });
+
+ it('create project with unicode name, and spaces', function() {
+ var projectname = '応応応応 用用用用';
+ var projectid = 'com.test.app4';
+
+ createAndBuild(projectname, projectid);
+ });
+
+ it('create project with ascii+unicode name, no spaces', function() {
+ var projectname = '応応応応hello用用用用';
+ var projectid = 'com.test.app5';
+
+ createAndBuild(projectname, projectid);
+ });
+
+ it('create project with ascii+unicode name, and spaces', function() {
+ var projectname = '応応応応 hello 用用用用';
+ var projectid = 'com.test.app6';
+
+ createAndBuild(projectname, projectid);
+ });
+
+});
+
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/44578d2f/spec/projectApi.spec.js
----------------------------------------------------------------------
diff --git a/spec/projectApi.spec.js b/spec/projectApi.spec.js
new file mode 100644
index 0000000..d71a961
--- /dev/null
+++ b/spec/projectApi.spec.js
@@ -0,0 +1,116 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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 Api = require("../bin/template/cordova/Api");
+
+describe('can get the Api', function() {
+
+ it('should be defined', function() {
+ expect(Api).toBeDefined();
+ });
+
+ it('should export static createPlatform function', function(done) {
+ expect(Api.createPlatform).toBeDefined();
+ expect(typeof Api.createPlatform).toBe('function');
+
+// TODO: make this do something real
+ var promise = Api.createPlatform("../tmp");
+ expect(promise).toBeDefined();
+ expect(promise.then).toBeDefined();
+ promise.then(function(res) {
+ console.log('result = ' + res);
+ console.log("spec-success");
+ done();
+ },
+ function(err) {
+ console.log("spec-error " + err);
+ done();
+ });
+ });
+
+ it('should export static updatePlatform function', function() {
+ expect(Api.updatePlatform).toBeDefined();
+ expect(typeof Api.updatePlatform).toBe('function');
+ });
+
+});
+
+describe('project level Api',function() {
+
+ var testApi = new Api();
+
+ it('can be created', function() {
+ expect(testApi).toBeDefined();
+ });
+
+ it('has a requirements method', function() {
+ expect(testApi.requirements).toBeDefined();
+ expect(typeof testApi.requirements).toBe('function');
+ });
+
+ it('has a clean method', function() {
+ expect(testApi.clean).toBeDefined();
+ expect(typeof testApi.clean).toBe('function');
+ });
+
+ it('has a run method', function() {
+ expect(testApi.run).toBeDefined();
+ expect(typeof testApi.run).toBe('function');
+ });
+
+ it('has a build method', function() {
+ expect(testApi.build).toBeDefined();
+ expect(typeof testApi.build).toBe('function');
+ });
+
+ it('has a removePlugin method', function() {
+ expect(testApi.removePlugin).toBeDefined();
+ expect(typeof testApi.removePlugin).toBe('function');
+ });
+
+ it('has a addPlugin method', function() {
+ expect(testApi.addPlugin).toBeDefined();
+ expect(typeof testApi.addPlugin).toBe('function');
+ });
+
+ it('has a prepare method', function() {
+ expect(testApi.prepare).toBeDefined();
+ expect(typeof testApi.prepare).toBe('function');
+ });
+
+ it('has a getPlatformInfo method', function() {
+ expect(testApi.getPlatformInfo).toBeDefined();
+ expect(typeof testApi.getPlatformInfo).toBe('function');
+ });
+
+});
+
+// Static methods
+// Static method: createPlatform
+ // returns promise fulfilled with Api
+ // emits error using provided emmitter on error
+
+// Static method: updatePlatform
+ // returns a promise fulfilled with an Api
+ // emits error using provided emmitter on error
+ //
+
+// Instance methods
+ // requirements, clean, run, build, removePlugin, addPlugin, prepare, getPlatformInfo
+
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/44578d2f/spec/support/jasmine.json
----------------------------------------------------------------------
diff --git a/spec/support/jasmine.json b/spec/support/jasmine.json
new file mode 100644
index 0000000..7122dfd
--- /dev/null
+++ b/spec/support/jasmine.json
@@ -0,0 +1,10 @@
+{
+ "spec_dir": "spec",
+ "spec_files": [
+ "*[sS]pec.js"
+ ],
+ "helpers": [
+ ],
+ "stopSpecOnExpectationFailure": false,
+ "random": false
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[24/25] cordova-browser git commit: remove bundled dep on and move
shelljs to reasonable version
Posted by pu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/cp.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/cp.js b/node_modules/shelljs/src/cp.js
index 04c4e57..ef19f96 100644
--- a/node_modules/shelljs/src/cp.js
+++ b/node_modules/shelljs/src/cp.js
@@ -3,79 +3,42 @@ var path = require('path');
var common = require('./common');
var os = require('os');
-common.register('cp', _cp, {
- cmdOptions: {
- 'f': '!no_force',
- 'n': 'no_force',
- 'u': 'update',
- 'R': 'recursive',
- 'r': 'recursive',
- 'L': 'followsymlink',
- 'P': 'noFollowsymlink',
- },
- wrapOutput: false,
-});
-
// Buffered file copy, synchronous
// (Using readFileSync() + writeFileSync() could easily cause a memory overflow
// with large files)
-function copyFileSync(srcFile, destFile, options) {
- if (!fs.existsSync(srcFile)) {
+function copyFileSync(srcFile, destFile) {
+ if (!fs.existsSync(srcFile))
common.error('copyFileSync: no such file or directory: ' + srcFile);
- }
- // Check the mtimes of the files if the '-u' flag is provided
+ var BUF_LENGTH = 64*1024,
+ buf = new Buffer(BUF_LENGTH),
+ bytesRead = BUF_LENGTH,
+ pos = 0,
+ fdr = null,
+ fdw = null;
+
try {
- if (options.update && fs.statSync(srcFile).mtime < fs.statSync(destFile).mtime) {
- return;
- }
- } catch (e) {
- // If we're here, destFile probably doesn't exist, so just do a normal copy
+ fdr = fs.openSync(srcFile, 'r');
+ } catch(e) {
+ common.error('copyFileSync: could not read src file ('+srcFile+')');
}
- if (fs.lstatSync(srcFile).isSymbolicLink() && !options.followsymlink) {
- try {
- fs.lstatSync(destFile);
- common.unlinkSync(destFile); // re-link it
- } catch (e) {
- // it doesn't exist, so no work needs to be done
- }
-
- var symlinkFull = fs.readlinkSync(srcFile);
- fs.symlinkSync(symlinkFull, destFile, os.platform() === 'win32' ? 'junction' : null);
- } else {
- var BUF_LENGTH = 64 * 1024;
- var buf = new Buffer(BUF_LENGTH);
- var bytesRead = BUF_LENGTH;
- var pos = 0;
- var fdr = null;
- var fdw = null;
-
- try {
- fdr = fs.openSync(srcFile, 'r');
- } catch (e) {
- /* istanbul ignore next */
- common.error('copyFileSync: could not read src file (' + srcFile + ')');
- }
-
- try {
- fdw = fs.openSync(destFile, 'w');
- } catch (e) {
- /* istanbul ignore next */
- common.error('copyFileSync: could not write to dest file (code=' + e.code + '):' + destFile);
- }
+ try {
+ fdw = fs.openSync(destFile, 'w');
+ } catch(e) {
+ common.error('copyFileSync: could not write to dest file (code='+e.code+'):'+destFile);
+ }
- while (bytesRead === BUF_LENGTH) {
- bytesRead = fs.readSync(fdr, buf, 0, BUF_LENGTH, pos);
- fs.writeSync(fdw, buf, 0, bytesRead);
- pos += bytesRead;
- }
+ while (bytesRead === BUF_LENGTH) {
+ bytesRead = fs.readSync(fdr, buf, 0, BUF_LENGTH, pos);
+ fs.writeSync(fdw, buf, 0, bytesRead);
+ pos += bytesRead;
+ }
- fs.closeSync(fdr);
- fs.closeSync(fdw);
+ fs.closeSync(fdr);
+ fs.closeSync(fdw);
- fs.chmodSync(destFile, fs.statSync(srcFile).mode);
- }
+ fs.chmodSync(destFile, fs.statSync(srcFile).mode);
}
// Recursively copies 'sourceDir' into 'destDir'
@@ -86,193 +49,156 @@ function copyFileSync(srcFile, destFile, options) {
//
// Licensed under the MIT License
// http://www.opensource.org/licenses/mit-license.php
-function cpdirSyncRecursive(sourceDir, destDir, currentDepth, opts) {
+function cpdirSyncRecursive(sourceDir, destDir, opts) {
if (!opts) opts = {};
- // Ensure there is not a run away recursive copy
- if (currentDepth >= common.config.maxdepth) return;
- currentDepth++;
-
- // Create the directory where all our junk is moving to; read the mode of the
- // source directory and mirror it
+ /* Create the directory where all our junk is moving to; read the mode of the source directory and mirror it */
+ var checkDir = fs.statSync(sourceDir);
try {
- var checkDir = fs.statSync(sourceDir);
fs.mkdirSync(destDir, checkDir.mode);
} catch (e) {
- // if the directory already exists, that's okay
+ //if the directory already exists, that's okay
if (e.code !== 'EEXIST') throw e;
}
var files = fs.readdirSync(sourceDir);
for (var i = 0; i < files.length; i++) {
- var srcFile = sourceDir + '/' + files[i];
- var destFile = destDir + '/' + files[i];
+ var srcFile = sourceDir + "/" + files[i];
+ var destFile = destDir + "/" + files[i];
var srcFileStat = fs.lstatSync(srcFile);
- var symlinkFull;
- if (opts.followsymlink) {
- if (cpcheckcycle(sourceDir, srcFile)) {
- // Cycle link found.
- console.error('Cycle link found.');
- symlinkFull = fs.readlinkSync(srcFile);
- fs.symlinkSync(symlinkFull, destFile, os.platform() === 'win32' ? 'junction' : null);
- continue;
- }
- }
if (srcFileStat.isDirectory()) {
/* recursion this thing right on back. */
- cpdirSyncRecursive(srcFile, destFile, currentDepth, opts);
- } else if (srcFileStat.isSymbolicLink() && !opts.followsymlink) {
- symlinkFull = fs.readlinkSync(srcFile);
- try {
- fs.lstatSync(destFile);
- common.unlinkSync(destFile); // re-link it
- } catch (e) {
- // it doesn't exist, so no work needs to be done
- }
- fs.symlinkSync(symlinkFull, destFile, os.platform() === 'win32' ? 'junction' : null);
- } else if (srcFileStat.isSymbolicLink() && opts.followsymlink) {
- srcFileStat = fs.statSync(srcFile);
- if (srcFileStat.isDirectory()) {
- cpdirSyncRecursive(srcFile, destFile, currentDepth, opts);
- } else {
- copyFileSync(srcFile, destFile, opts);
- }
+ cpdirSyncRecursive(srcFile, destFile, opts);
+ } else if (srcFileStat.isSymbolicLink()) {
+ var symlinkFull = fs.readlinkSync(srcFile);
+ fs.symlinkSync(symlinkFull, destFile, os.platform() === "win32" ? "junction" : null);
} else {
/* At this point, we've hit a file actually worth copying... so copy it on over. */
- if (fs.existsSync(destFile) && opts.no_force) {
+ if (fs.existsSync(destFile) && !opts.force) {
common.log('skipping existing file: ' + files[i]);
} else {
- copyFileSync(srcFile, destFile, opts);
+ copyFileSync(srcFile, destFile);
}
}
+
} // for files
} // cpdirSyncRecursive
-function cpcheckcycle(sourceDir, srcFile) {
- var srcFileStat = fs.lstatSync(srcFile);
- if (srcFileStat.isSymbolicLink()) {
- // Do cycle check. For example:
- // $ mkdir -p 1/2/3/4
- // $ cd 1/2/3/4
- // $ ln -s ../../3 link
- // $ cd ../../../..
- // $ cp -RL 1 copy
- var cyclecheck = fs.statSync(srcFile);
- if (cyclecheck.isDirectory()) {
- var sourcerealpath = fs.realpathSync(sourceDir);
- var symlinkrealpath = fs.realpathSync(srcFile);
- var re = new RegExp(symlinkrealpath);
- if (re.test(sourcerealpath)) {
- return true;
- }
- }
- }
- return false;
-}
//@
-//@ ### cp([options,] source [, source ...], dest)
-//@ ### cp([options,] source_array, dest)
+//@ ### cp([options ,] source [,source ...], dest)
+//@ ### cp([options ,] source_array, dest)
//@ Available options:
//@
-//@ + `-f`: force (default behavior)
-//@ + `-n`: no-clobber
-//@ + `-u`: only copy if source is newer than dest
-//@ + `-r`, `-R`: recursive
-//@ + `-L`: follow symlinks
-//@ + `-P`: don't follow symlinks
+//@ + `-f`: force
+//@ + `-r, -R`: recursive
//@
//@ Examples:
//@
//@ ```javascript
//@ cp('file1', 'dir1');
-//@ cp('-R', 'path/to/dir/', '~/newCopy/');
//@ cp('-Rf', '/tmp/*', '/usr/local/*', '/home/tmp');
//@ cp('-Rf', ['/tmp/*', '/usr/local/*'], '/home/tmp'); // same as above
//@ ```
//@
-//@ Copies files.
+//@ Copies files. The wildcard `*` is accepted.
function _cp(options, sources, dest) {
- // If we're missing -R, it actually implies -L (unless -P is explicit)
- if (options.followsymlink) {
- options.noFollowsymlink = false;
- }
- if (!options.recursive && !options.noFollowsymlink) {
- options.followsymlink = true;
- }
+ options = common.parseOptions(options, {
+ 'f': 'force',
+ 'R': 'recursive',
+ 'r': 'recursive'
+ });
// Get sources, dest
if (arguments.length < 3) {
common.error('missing <source> and/or <dest>');
- } else {
+ } else if (arguments.length > 3) {
sources = [].slice.call(arguments, 1, arguments.length - 1);
dest = arguments[arguments.length - 1];
+ } else if (typeof sources === 'string') {
+ sources = [sources];
+ } else if ('length' in sources) {
+ sources = sources; // no-op for array
+ } else {
+ common.error('invalid arguments');
}
- var destExists = fs.existsSync(dest);
- var destStat = destExists && fs.statSync(dest);
+ var exists = fs.existsSync(dest),
+ stats = exists && fs.statSync(dest);
// Dest is not existing dir, but multiple sources given
- if ((!destExists || !destStat.isDirectory()) && sources.length > 1) {
+ if ((!exists || !stats.isDirectory()) && sources.length > 1)
common.error('dest is not a directory (too many sources)');
- }
- // Dest is an existing file, but -n is given
- if (destExists && destStat.isFile() && options.no_force) {
- return new common.ShellString('', '', 0);
+ // Dest is an existing file, but no -f given
+ if (exists && stats.isFile() && !options.force)
+ common.error('dest file already exists: ' + dest);
+
+ if (options.recursive) {
+ // Recursive allows the shortcut syntax "sourcedir/" for "sourcedir/*"
+ // (see Github issue #15)
+ sources.forEach(function(src, i) {
+ if (src[src.length - 1] === '/')
+ sources[i] += '*';
+ });
+
+ // Create dest
+ try {
+ fs.mkdirSync(dest, parseInt('0777', 8));
+ } catch (e) {
+ // like Unix's cp, keep going even if we can't create dest dir
+ }
}
- sources.forEach(function (src) {
+ sources = common.expand(sources);
+
+ sources.forEach(function(src) {
if (!fs.existsSync(src)) {
- common.error('no such file or directory: ' + src, { continue: true });
+ common.error('no such file or directory: '+src, true);
return; // skip file
}
- var srcStat = fs.statSync(src);
- if (!options.noFollowsymlink && srcStat.isDirectory()) {
+
+ // If here, src exists
+ if (fs.statSync(src).isDirectory()) {
if (!options.recursive) {
// Non-Recursive
- common.error("omitting directory '" + src + "'", { continue: true });
+ common.log(src + ' is a directory (not copied)');
} else {
// Recursive
// 'cp /a/source dest' should create 'source' in 'dest'
- var newDest = (destStat && destStat.isDirectory()) ?
- path.join(dest, path.basename(src)) :
- dest;
-
+ var newDest = path.join(dest, path.basename(src)),
+ checkDir = fs.statSync(src);
try {
- fs.statSync(path.dirname(dest));
- cpdirSyncRecursive(src, newDest, 0, { no_force: options.no_force, followsymlink: options.followsymlink });
+ fs.mkdirSync(newDest, checkDir.mode);
} catch (e) {
- /* istanbul ignore next */
- common.error("cannot create directory '" + dest + "': No such file or directory");
+ //if the directory already exists, that's okay
+ if (e.code !== 'EEXIST') {
+ common.error('dest file no such file or directory: ' + newDest, true);
+ throw e;
+ }
}
- }
- } else {
- // If here, src is a file
- // When copying to '/path/dir':
- // thisDest = '/path/dir/file1'
- var thisDest = dest;
- if (destStat && destStat.isDirectory()) {
- thisDest = path.normalize(dest + '/' + path.basename(src));
+ cpdirSyncRecursive(src, newDest, {force: options.force});
}
+ return; // done with dir
+ }
- if (fs.existsSync(thisDest) && options.no_force) {
- return; // skip file
- }
+ // If here, src is a file
- if (path.relative(src, thisDest) === '') {
- // a file cannot be copied to itself, but we want to continue copying other files
- common.error("'" + thisDest + "' and '" + src + "' are the same file", { continue: true });
- return;
- }
+ // When copying to '/path/dir':
+ // thisDest = '/path/dir/file1'
+ var thisDest = dest;
+ if (fs.existsSync(dest) && fs.statSync(dest).isDirectory())
+ thisDest = path.normalize(dest + '/' + path.basename(src));
- copyFileSync(src, thisDest, options);
+ if (fs.existsSync(thisDest) && !options.force) {
+ common.error('dest file already exists: ' + thisDest, true);
+ return; // skip file
}
- }); // forEach(src)
- return new common.ShellString('', common.state.error, common.state.errorCode);
+ copyFileSync(src, thisDest);
+ }); // forEach(src)
}
module.exports = _cp;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/dirs.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/dirs.js b/node_modules/shelljs/src/dirs.js
index 3806c14..58fae8b 100644
--- a/node_modules/shelljs/src/dirs.js
+++ b/node_modules/shelljs/src/dirs.js
@@ -2,16 +2,6 @@ var common = require('./common');
var _cd = require('./cd');
var path = require('path');
-common.register('dirs', _dirs, {
- wrapOutput: false,
-});
-common.register('pushd', _pushd, {
- wrapOutput: false,
-});
-common.register('popd', _popd, {
- wrapOutput: false,
-});
-
// Pushd/popd/dirs internals
var _dirStack = [];
@@ -23,8 +13,9 @@ function _parseStackIndex(index) {
if (_isStackIndex(index)) {
if (Math.abs(index) < _dirStack.length + 1) { // +1 for pwd
return (/^-/).test(index) ? Number(index) - 1 : Number(index);
+ } else {
+ common.error(index + ': directory stack index out of range');
}
- common.error(index + ': directory stack index out of range');
} else {
common.error(index + ': invalid number');
}
@@ -63,7 +54,7 @@ function _pushd(options, dir) {
}
options = common.parseOptions(options, {
- 'n': 'no-cd',
+ 'n' : 'no-cd'
});
var dirs = _actualDirStack();
@@ -129,7 +120,7 @@ function _popd(options, index) {
}
options = common.parseOptions(options, {
- 'n': 'no-cd',
+ 'n' : 'no-cd'
});
if (!_dirStack.length) {
@@ -172,10 +163,10 @@ function _dirs(options, index) {
}
options = common.parseOptions(options, {
- 'c': 'clear',
+ 'c' : 'clear'
});
- if (options.clear) {
+ if (options['clear']) {
_dirStack = [];
return _dirStack;
}
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/echo.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/echo.js b/node_modules/shelljs/src/echo.js
index 2b0e7d9..760ea84 100644
--- a/node_modules/shelljs/src/echo.js
+++ b/node_modules/shelljs/src/echo.js
@@ -1,14 +1,7 @@
var common = require('./common');
-common.register('echo', _echo, {
- allowGlobbing: false,
-});
-
-//@
-//@ ### echo([options,] string [, string ...])
-//@ Available options:
//@
-//@ + `-e`: interpret backslash escapes (default)
+//@ ### echo(string [,string ...])
//@
//@ Examples:
//@
@@ -19,16 +12,9 @@ common.register('echo', _echo, {
//@
//@ Prints string to stdout, and returns string with additional utility methods
//@ like `.to()`.
-function _echo(opts, messages) {
- // allow strings starting with '-', see issue #20
- messages = [].slice.call(arguments, opts ? 0 : 1);
-
- if (messages[0] === '-e') {
- // ignore -e
- messages.shift();
- }
-
- console.log.apply(console, messages);
- return messages.join(' ');
+function _echo() {
+ var messages = [].slice.call(arguments, 0);
+ console.log.apply(this, messages);
+ return common.ShellString(messages.join(' '));
}
module.exports = _echo;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/error.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/error.js b/node_modules/shelljs/src/error.js
index 507c86d..cca3efb 100644
--- a/node_modules/shelljs/src/error.js
+++ b/node_modules/shelljs/src/error.js
@@ -2,13 +2,9 @@ var common = require('./common');
//@
//@ ### error()
-//@ Tests if error occurred in the last command. Returns a truthy value if an
-//@ error returned and a falsy value otherwise.
-//@
-//@ **Note**: do not rely on the
-//@ return value to be an error message. If you need the last error message, use
-//@ the `.stderr` attribute from the last command's return value instead.
+//@ Tests if error occurred in the last command. Returns `null` if no error occurred,
+//@ otherwise returns string explaining the error
function error() {
return common.state.error;
-}
+};
module.exports = error;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/exec.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/exec.js b/node_modules/shelljs/src/exec.js
index 5d360e8..d259a9f 100644
--- a/node_modules/shelljs/src/exec.js
+++ b/node_modules/shelljs/src/exec.js
@@ -5,157 +5,101 @@ var path = require('path');
var fs = require('fs');
var child = require('child_process');
-var DEFAULT_MAXBUFFER_SIZE = 20 * 1024 * 1024;
-
-common.register('exec', _exec, {
- unix: false,
- canReceivePipe: true,
- wrapOutput: false,
-});
-
// Hack to run child_process.exec() synchronously (sync avoids callback hell)
// Uses a custom wait loop that checks for a flag file, created when the child process is done.
// (Can't do a wait loop that checks for internal Node variables/messages as
// Node is single-threaded; callbacks and other internal state changes are done in the
// event loop).
-function execSync(cmd, opts, pipe) {
- if (!common.config.execPath) {
- common.error('Unable to find a path to the node binary. Please manually set config.execPath');
- }
-
+function execSync(cmd, opts) {
var tempDir = _tempDir();
- var stdoutFile = path.resolve(tempDir + '/' + common.randomFileName());
- var stderrFile = path.resolve(tempDir + '/' + common.randomFileName());
- var codeFile = path.resolve(tempDir + '/' + common.randomFileName());
- var scriptFile = path.resolve(tempDir + '/' + common.randomFileName());
- var sleepFile = path.resolve(tempDir + '/' + common.randomFileName());
+ var stdoutFile = path.resolve(tempDir+'/'+common.randomFileName()),
+ codeFile = path.resolve(tempDir+'/'+common.randomFileName()),
+ scriptFile = path.resolve(tempDir+'/'+common.randomFileName()),
+ sleepFile = path.resolve(tempDir+'/'+common.randomFileName());
- opts = common.extend({
- silent: common.config.silent,
- cwd: _pwd().toString(),
- env: process.env,
- maxBuffer: DEFAULT_MAXBUFFER_SIZE,
+ var options = common.extend({
+ silent: common.config.silent
}, opts);
var previousStdoutContent = '';
- var previousStderrContent = '';
- // Echoes stdout and stderr changes from running process, if not silent
- function updateStream(streamFile) {
- if (opts.silent || !fs.existsSync(streamFile)) {
+ // Echoes stdout changes from running process, if not silent
+ function updateStdout() {
+ if (options.silent || !fs.existsSync(stdoutFile))
return;
- }
- var previousStreamContent;
- var procStream;
- if (streamFile === stdoutFile) {
- previousStreamContent = previousStdoutContent;
- procStream = process.stdout;
- } else { // assume stderr
- previousStreamContent = previousStderrContent;
- procStream = process.stderr;
- }
-
- var streamContent = fs.readFileSync(streamFile, 'utf8');
+ var stdoutContent = fs.readFileSync(stdoutFile, 'utf8');
// No changes since last time?
- if (streamContent.length <= previousStreamContent.length) {
+ if (stdoutContent.length <= previousStdoutContent.length)
return;
- }
- procStream.write(streamContent.substr(previousStreamContent.length));
- previousStreamContent = streamContent;
+ process.stdout.write(stdoutContent.substr(previousStdoutContent.length));
+ previousStdoutContent = stdoutContent;
+ }
+
+ function escape(str) {
+ return (str+'').replace(/([\\"'])/g, "\\$1").replace(/\0/g, "\\0");
}
if (fs.existsSync(scriptFile)) common.unlinkSync(scriptFile);
if (fs.existsSync(stdoutFile)) common.unlinkSync(stdoutFile);
- if (fs.existsSync(stderrFile)) common.unlinkSync(stderrFile);
if (fs.existsSync(codeFile)) common.unlinkSync(codeFile);
- var execCommand = JSON.stringify(common.config.execPath) + ' ' + JSON.stringify(scriptFile);
- var script;
-
- opts.cwd = path.resolve(opts.cwd);
- var optString = JSON.stringify(opts);
+ var execCommand = '"'+process.execPath+'" '+scriptFile;
+ var execOptions = {
+ env: process.env,
+ cwd: _pwd(),
+ maxBuffer: 20*1024*1024
+ };
if (typeof child.execSync === 'function') {
- script = [
+ var script = [
"var child = require('child_process')",
" , fs = require('fs');",
- 'var childProcess = child.exec(' + JSON.stringify(cmd) + ', ' + optString + ', function(err) {',
- ' var fname = ' + JSON.stringify(codeFile) + ';',
- ' if (!err) {',
- ' fs.writeFileSync(fname, "0");',
- ' } else if (err.code === undefined) {',
- ' fs.writeFileSync(fname, "1");',
- ' } else {',
- ' fs.writeFileSync(fname, err.code.toString());',
- ' }',
- '});',
- 'var stdoutStream = fs.createWriteStream(' + JSON.stringify(stdoutFile) + ');',
- 'var stderrStream = fs.createWriteStream(' + JSON.stringify(stderrFile) + ');',
- 'childProcess.stdout.pipe(stdoutStream, {end: false});',
- 'childProcess.stderr.pipe(stderrStream, {end: false});',
- 'childProcess.stdout.pipe(process.stdout);',
- 'childProcess.stderr.pipe(process.stderr);',
- ].join('\n') +
- (pipe ? '\nchildProcess.stdin.end(' + JSON.stringify(pipe) + ');\n' : '\n') +
- [
- 'var stdoutEnded = false, stderrEnded = false;',
- 'function tryClosingStdout(){ if(stdoutEnded){ stdoutStream.end(); } }',
- 'function tryClosingStderr(){ if(stderrEnded){ stderrStream.end(); } }',
- "childProcess.stdout.on('end', function(){ stdoutEnded = true; tryClosingStdout(); });",
- "childProcess.stderr.on('end', function(){ stderrEnded = true; tryClosingStderr(); });",
- ].join('\n');
+ "var childProcess = child.exec('"+escape(cmd)+"', {env: process.env, maxBuffer: 20*1024*1024}, function(err) {",
+ " fs.writeFileSync('"+escape(codeFile)+"', err ? err.code.toString() : '0');",
+ "});",
+ "var stdoutStream = fs.createWriteStream('"+escape(stdoutFile)+"');",
+ "childProcess.stdout.pipe(stdoutStream, {end: false});",
+ "childProcess.stderr.pipe(stdoutStream, {end: false});",
+ "childProcess.stdout.pipe(process.stdout);",
+ "childProcess.stderr.pipe(process.stderr);",
+ "var stdoutEnded = false, stderrEnded = false;",
+ "function tryClosing(){ if(stdoutEnded && stderrEnded){ stdoutStream.end(); } }",
+ "childProcess.stdout.on('end', function(){ stdoutEnded = true; tryClosing(); });",
+ "childProcess.stderr.on('end', function(){ stderrEnded = true; tryClosing(); });"
+ ].join('\n');
fs.writeFileSync(scriptFile, script);
- if (opts.silent) {
- opts.stdio = 'ignore';
+ if (options.silent) {
+ execOptions.stdio = 'ignore';
} else {
- opts.stdio = [0, 1, 2];
+ execOptions.stdio = [0, 1, 2];
}
// Welcome to the future
- try {
- child.execSync(execCommand, opts);
- } catch (e) {
- // Clean up immediately if we have an exception
- try { common.unlinkSync(scriptFile); } catch (e2) {}
- try { common.unlinkSync(stdoutFile); } catch (e2) {}
- try { common.unlinkSync(stderrFile); } catch (e2) {}
- try { common.unlinkSync(codeFile); } catch (e2) {}
- throw e;
- }
+ child.execSync(execCommand, execOptions);
} else {
- cmd += ' > ' + stdoutFile + ' 2> ' + stderrFile; // works on both win/unix
+ cmd += ' > '+stdoutFile+' 2>&1'; // works on both win/unix
- script = [
+ var script = [
"var child = require('child_process')",
" , fs = require('fs');",
- 'var childProcess = child.exec(' + JSON.stringify(cmd) + ', ' + optString + ', function(err) {',
- ' var fname = ' + JSON.stringify(codeFile) + ';',
- ' if (!err) {',
- ' fs.writeFileSync(fname, "0");',
- ' } else if (err.code === undefined) {',
- ' fs.writeFileSync(fname, "1");',
- ' } else {',
- ' fs.writeFileSync(fname, err.code.toString());',
- ' }',
- '});',
- ].join('\n') +
- (pipe ? '\nchildProcess.stdin.end(' + JSON.stringify(pipe) + ');\n' : '\n');
+ "var childProcess = child.exec('"+escape(cmd)+"', {env: process.env, maxBuffer: 20*1024*1024}, function(err) {",
+ " fs.writeFileSync('"+escape(codeFile)+"', err ? err.code.toString() : '0');",
+ "});"
+ ].join('\n');
fs.writeFileSync(scriptFile, script);
- child.exec(execCommand, opts);
+ child.exec(execCommand, execOptions);
// The wait loop
// sleepFile is used as a dummy I/O op to mitigate unnecessary CPU usage
// (tried many I/O sync ops, writeFileSync() seems to be only one that is effective in reducing
// CPU usage, though apparently not so much on Windows)
- while (!fs.existsSync(codeFile)) { updateStream(stdoutFile); fs.writeFileSync(sleepFile, 'a'); }
- while (!fs.existsSync(stdoutFile)) { updateStream(stdoutFile); fs.writeFileSync(sleepFile, 'a'); }
- while (!fs.existsSync(stderrFile)) { updateStream(stderrFile); fs.writeFileSync(sleepFile, 'a'); }
- try { common.unlinkSync(sleepFile); } catch (e) {}
+ while (!fs.existsSync(codeFile)) { updateStdout(); fs.writeFileSync(sleepFile, 'a'); }
+ while (!fs.existsSync(stdoutFile)) { updateStdout(); fs.writeFileSync(sleepFile, 'a'); }
}
// At this point codeFile exists, but it's not necessarily flushed yet.
@@ -166,56 +110,48 @@ function execSync(cmd, opts, pipe) {
}
var stdout = fs.readFileSync(stdoutFile, 'utf8');
- var stderr = fs.readFileSync(stderrFile, 'utf8');
// No biggie if we can't erase the files now -- they're in a temp dir anyway
- try { common.unlinkSync(scriptFile); } catch (e) {}
- try { common.unlinkSync(stdoutFile); } catch (e) {}
- try { common.unlinkSync(stderrFile); } catch (e) {}
- try { common.unlinkSync(codeFile); } catch (e) {}
-
- if (code !== 0) {
- common.error('', code, { continue: true });
+ try { common.unlinkSync(scriptFile); } catch(e) {}
+ try { common.unlinkSync(stdoutFile); } catch(e) {}
+ try { common.unlinkSync(codeFile); } catch(e) {}
+ try { common.unlinkSync(sleepFile); } catch(e) {}
+
+ // some shell return codes are defined as errors, per http://tldp.org/LDP/abs/html/exitcodes.html
+ if (code === 1 || code === 2 || code >= 126) {
+ common.error('', true); // unix/shell doesn't really give an error message after non-zero exit codes
}
- var obj = common.ShellString(stdout, stderr, code);
+ // True if successful, false if not
+ var obj = {
+ code: code,
+ output: stdout
+ };
return obj;
} // execSync()
// Wrapper around exec() to enable echoing output to console in real time
-function execAsync(cmd, opts, pipe, callback) {
- var stdout = '';
- var stderr = '';
+function execAsync(cmd, opts, callback) {
+ var output = '';
- opts = common.extend({
- silent: common.config.silent,
- cwd: _pwd().toString(),
- env: process.env,
- maxBuffer: DEFAULT_MAXBUFFER_SIZE,
+ var options = common.extend({
+ silent: common.config.silent
}, opts);
- var c = child.exec(cmd, opts, function (err) {
- if (callback) {
- if (!err) {
- callback(0, stdout, stderr);
- } else if (err.code === undefined) {
- // See issue #536
- callback(1, stdout, stderr);
- } else {
- callback(err.code, stdout, stderr);
- }
- }
+ var c = child.exec(cmd, {env: process.env, maxBuffer: 20*1024*1024}, function(err) {
+ if (callback)
+ callback(err ? err.code : 0, output);
});
- if (pipe) c.stdin.end(pipe);
-
- c.stdout.on('data', function (data) {
- stdout += data;
- if (!opts.silent) process.stdout.write(data);
+ c.stdout.on('data', function(data) {
+ output += data;
+ if (!options.silent)
+ process.stdout.write(data);
});
- c.stderr.on('data', function (data) {
- stderr += data;
- if (!opts.silent) process.stderr.write(data);
+ c.stderr.on('data', function(data) {
+ output += data;
+ if (!options.silent)
+ process.stdout.write(data);
});
return c;
@@ -225,46 +161,36 @@ function execAsync(cmd, opts, pipe, callback) {
//@ ### exec(command [, options] [, callback])
//@ Available options (all `false` by default):
//@
-//@ + `async`: Asynchronous execution. If a callback is provided, it will be set to
-//@ `true`, regardless of the passed value.
+//@ + `async`: Asynchronous execution. Defaults to true if a callback is provided.
//@ + `silent`: Do not echo program output to console.
-//@ + and any option available to Node.js's
-//@ [child_process.exec()](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback)
//@
//@ Examples:
//@
//@ ```javascript
-//@ var version = exec('node --version', {silent:true}).stdout;
+//@ var version = exec('node --version', {silent:true}).output;
//@
//@ var child = exec('some_long_running_process', {async:true});
//@ child.stdout.on('data', function(data) {
//@ /* ... do something with data ... */
//@ });
//@
-//@ exec('some_long_running_process', function(code, stdout, stderr) {
+//@ exec('some_long_running_process', function(code, output) {
//@ console.log('Exit code:', code);
-//@ console.log('Program output:', stdout);
-//@ console.log('Program stderr:', stderr);
+//@ console.log('Program output:', output);
//@ });
//@ ```
//@
-//@ Executes the given `command` _synchronously_, unless otherwise specified. When in synchronous
-//@ mode, this returns a ShellString (compatible with ShellJS v0.6.x, which returns an object
-//@ of the form `{ code:..., stdout:... , stderr:... }`). Otherwise, this returns the child process
-//@ object, and the `callback` gets the arguments `(code, stdout, stderr)`.
-//@
-//@ Not seeing the behavior you want? `exec()` runs everything through `sh`
-//@ by default (or `cmd.exe` on Windows), which differs from `bash`. If you
-//@ need bash-specific behavior, try out the `{shell: 'path/to/bash'}` option.
+//@ Executes the given `command` _synchronously_, unless otherwise specified.
+//@ When in synchronous mode returns the object `{ code:..., output:... }`, containing the program's
+//@ `output` (stdout + stderr) and its exit `code`. Otherwise returns the child process object, and
+//@ the `callback` gets the arguments `(code, output)`.
//@
//@ **Note:** For long-lived processes, it's best to run `exec()` asynchronously as
//@ the current synchronous implementation uses a lot of CPU. This should be getting
//@ fixed soon.
function _exec(command, options, callback) {
- options = options || {};
- if (!command) common.error('must specify command');
-
- var pipe = common.readFromPipe();
+ if (!command)
+ common.error('must specify command');
// Callback is defined instead of options.
if (typeof options === 'function') {
@@ -279,17 +205,12 @@ function _exec(command, options, callback) {
options = common.extend({
silent: common.config.silent,
- async: false,
+ async: false
}, options);
- try {
- if (options.async) {
- return execAsync(command, options, pipe, callback);
- } else {
- return execSync(command, options, pipe);
- }
- } catch (e) {
- common.error('internal error');
- }
+ if (options.async)
+ return execAsync(command, options, callback);
+ else
+ return execSync(command, options);
}
module.exports = _exec;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/find.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/find.js b/node_modules/shelljs/src/find.js
index 625aa29..d9eeec2 100644
--- a/node_modules/shelljs/src/find.js
+++ b/node_modules/shelljs/src/find.js
@@ -1,12 +1,9 @@
var fs = require('fs');
-var path = require('path');
var common = require('./common');
var _ls = require('./ls');
-common.register('find', _find, {});
-
//@
-//@ ### find(path [, path ...])
+//@ ### find(path [,path ...])
//@ ### find(path_array)
//@ Examples:
//@
@@ -21,37 +18,30 @@ common.register('find', _find, {});
//@ The main difference from `ls('-R', path)` is that the resulting file names
//@ include the base directories, e.g. `lib/resources/file1` instead of just `file1`.
function _find(options, paths) {
- if (!paths) {
+ if (!paths)
common.error('no path specified');
- } else if (typeof paths === 'string') {
+ else if (typeof paths === 'object')
+ paths = paths; // assume array
+ else if (typeof paths === 'string')
paths = [].slice.call(arguments, 1);
- }
var list = [];
function pushFile(file) {
- if (common.platform === 'win') {
+ if (common.platform === 'win')
file = file.replace(/\\/g, '/');
- }
list.push(file);
}
// why not simply do ls('-R', paths)? because the output wouldn't give the base dirs
// to get the base dir in the output, we need instead ls('-R', 'dir/*') for every directory
- paths.forEach(function (file) {
- var stat;
- try {
- stat = fs.statSync(file);
- } catch (e) {
- common.error('no such file or directory: ' + file);
- }
-
+ paths.forEach(function(file) {
pushFile(file);
- if (stat.isDirectory()) {
- _ls({ recursive: true, all: true }, file).forEach(function (subfile) {
- pushFile(path.join(file, subfile));
+ if (fs.statSync(file).isDirectory()) {
+ _ls('-RA', file+'/*').forEach(function(subfile) {
+ pushFile(subfile);
});
}
});
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/grep.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/grep.js b/node_modules/shelljs/src/grep.js
index 30842bc..00c7d6a 100644
--- a/node_modules/shelljs/src/grep.js
+++ b/node_modules/shelljs/src/grep.js
@@ -1,22 +1,12 @@
var common = require('./common');
var fs = require('fs');
-common.register('grep', _grep, {
- globStart: 2, // don't glob-expand the regex
- canReceivePipe: true,
- cmdOptions: {
- 'v': 'inverse',
- 'l': 'nameOnly',
- },
-});
-
//@
-//@ ### grep([options,] regex_filter, file [, file ...])
-//@ ### grep([options,] regex_filter, file_array)
+//@ ### grep([options ,] regex_filter, file [, file ...])
+//@ ### grep([options ,] regex_filter, file_array)
//@ Available options:
//@
//@ + `-v`: Inverse the sense of the regex and print the lines not matching the criteria.
-//@ + `-l`: Print only filenames of matching files
//@
//@ Examples:
//@
@@ -26,42 +16,37 @@ common.register('grep', _grep, {
//@ ```
//@
//@ Reads input string from given files and returns a string containing all lines of the
-//@ file that match the given `regex_filter`.
+//@ file that match the given `regex_filter`. Wildcard `*` accepted.
function _grep(options, regex, files) {
- // Check if this is coming from a pipe
- var pipe = common.readFromPipe();
+ options = common.parseOptions(options, {
+ 'v': 'inverse'
+ });
- if (!files && !pipe) common.error('no paths given', 2);
+ if (!files)
+ common.error('no paths given');
- files = [].slice.call(arguments, 2);
+ if (typeof files === 'string')
+ files = [].slice.call(arguments, 2);
+ // if it's array leave it as it is
- if (pipe) {
- files.unshift('-');
- }
+ files = common.expand(files);
- var grep = [];
- files.forEach(function (file) {
- if (!fs.existsSync(file) && file !== '-') {
- common.error('no such file or directory: ' + file, 2, { continue: true });
+ var grep = '';
+ files.forEach(function(file) {
+ if (!fs.existsSync(file)) {
+ common.error('no such file or directory: ' + file, true);
return;
}
- var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8');
- var lines = contents.split(/\r*\n/);
- if (options.nameOnly) {
- if (contents.match(regex)) {
- grep.push(file);
- }
- } else {
- lines.forEach(function (line) {
- var matched = line.match(regex);
- if ((options.inverse && !matched) || (!options.inverse && matched)) {
- grep.push(line);
- }
- });
- }
+ var contents = fs.readFileSync(file, 'utf8'),
+ lines = contents.split(/\r*\n/);
+ lines.forEach(function(line) {
+ var matched = line.match(regex);
+ if ((options.inverse && !matched) || (!options.inverse && matched))
+ grep += line + '\n';
+ });
});
- return grep.join('\n') + '\n';
+ return common.ShellString(grep);
}
module.exports = _grep;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/ln.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/ln.js b/node_modules/shelljs/src/ln.js
index 7393d9f..a7b9701 100644
--- a/node_modules/shelljs/src/ln.js
+++ b/node_modules/shelljs/src/ln.js
@@ -1,20 +1,15 @@
var fs = require('fs');
var path = require('path');
var common = require('./common');
-
-common.register('ln', _ln, {
- cmdOptions: {
- 's': 'symlink',
- 'f': 'force',
- },
-});
+var os = require('os');
//@
-//@ ### ln([options,] source, dest)
+//@ ### ln(options, source, dest)
+//@ ### ln(source, dest)
//@ Available options:
//@
-//@ + `-s`: symlink
-//@ + `-f`: force
+//@ + `s`: symlink
+//@ + `f`: force
//@
//@ Examples:
//@
@@ -25,48 +20,34 @@ common.register('ln', _ln, {
//@
//@ Links source to dest. Use -f to force the link, should dest already exist.
function _ln(options, source, dest) {
+ options = common.parseOptions(options, {
+ 's': 'symlink',
+ 'f': 'force'
+ });
+
if (!source || !dest) {
common.error('Missing <source> and/or <dest>');
}
- source = String(source);
- var sourcePath = path.normalize(source).replace(RegExp(path.sep + '$'), '');
- var isAbsolute = (path.resolve(source) === sourcePath);
+ source = path.resolve(process.cwd(), String(source));
dest = path.resolve(process.cwd(), String(dest));
+ if (!fs.existsSync(source)) {
+ common.error('Source file does not exist', true);
+ }
+
if (fs.existsSync(dest)) {
if (!options.force) {
- common.error('Destination file exists', { continue: true });
+ common.error('Destination file exists', true);
}
fs.unlinkSync(dest);
}
if (options.symlink) {
- var isWindows = common.platform === 'win';
- var linkType = isWindows ? 'file' : null;
- var resolvedSourcePath = isAbsolute ? sourcePath : path.resolve(process.cwd(), path.dirname(dest), source);
- if (!fs.existsSync(resolvedSourcePath)) {
- common.error('Source file does not exist', { continue: true });
- } else if (isWindows && fs.statSync(resolvedSourcePath).isDirectory()) {
- linkType = 'junction';
- }
-
- try {
- fs.symlinkSync(linkType === 'junction' ? resolvedSourcePath : source, dest, linkType);
- } catch (err) {
- common.error(err.message);
- }
+ fs.symlinkSync(source, dest, os.platform() === "win32" ? "junction" : null);
} else {
- if (!fs.existsSync(source)) {
- common.error('Source file does not exist', { continue: true });
- }
- try {
- fs.linkSync(source, dest);
- } catch (err) {
- common.error(err.message);
- }
+ fs.linkSync(source, dest, os.platform() === "win32" ? "junction" : null);
}
- return '';
}
module.exports = _ln;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/ls.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/ls.js b/node_modules/shelljs/src/ls.js
index bb1b6a7..3345db4 100644
--- a/node_modules/shelljs/src/ls.js
+++ b/node_modules/shelljs/src/ls.js
@@ -1,34 +1,16 @@
var path = require('path');
var fs = require('fs');
var common = require('./common');
-var glob = require('glob');
-
-var globPatternRecursive = path.sep + '**';
-
-common.register('ls', _ls, {
- cmdOptions: {
- 'R': 'recursive',
- 'A': 'all',
- 'L': 'link',
- 'a': 'all_deprecated',
- 'd': 'directory',
- 'l': 'long',
- },
-});
+var _cd = require('./cd');
+var _pwd = require('./pwd');
//@
-//@ ### ls([options,] [path, ...])
-//@ ### ls([options,] path_array)
+//@ ### ls([options ,] path [,path ...])
+//@ ### ls([options ,] path_array)
//@ Available options:
//@
//@ + `-R`: recursive
//@ + `-A`: all files (include files beginning with `.`, except for `.` and `..`)
-//@ + `-L`: follow symlinks
-//@ + `-d`: list directories themselves, not their contents
-//@ + `-l`: list objects representing each file, each with fields containing `ls
-//@ -l` output fields. See
-//@ [fs.Stats](https://nodejs.org/api/fs.html#fs_class_fs_stats)
-//@ for more info
//@
//@ Examples:
//@
@@ -36,11 +18,16 @@ common.register('ls', _ls, {
//@ ls('projs/*.js');
//@ ls('-R', '/users/me', '/tmp');
//@ ls('-R', ['/users/me', '/tmp']); // same as above
-//@ ls('-l', 'file.txt'); // { name: 'file.txt', mode: 33188, nlink: 1, ...}
//@ ```
//@
//@ Returns array of files in the given path, or in current directory if no path provided.
function _ls(options, paths) {
+ options = common.parseOptions(options, {
+ 'R': 'recursive',
+ 'A': 'all',
+ 'a': 'all_deprecated'
+ });
+
if (options.all_deprecated) {
// We won't support the -a option as it's hard to image why it's useful
// (it includes '.' and '..' in addition to '.*' files)
@@ -49,78 +36,91 @@ function _ls(options, paths) {
options.all = true;
}
- if (!paths) {
+ if (!paths)
paths = ['.'];
- } else {
+ else if (typeof paths === 'object')
+ paths = paths; // assume array
+ else if (typeof paths === 'string')
paths = [].slice.call(arguments, 1);
- }
var list = [];
- function pushFile(abs, relName, stat) {
- if (process.platform === 'win32') {
- relName = relName.replace(/\\/g, '/');
- }
- if (options.long) {
- stat = stat || (options.link ? fs.statSync(abs) : fs.lstatSync(abs));
- list.push(addLsAttributes(relName, stat));
- } else {
- // list.push(path.relative(rel || '.', file));
- list.push(relName);
+ // Conditionally pushes file to list - returns true if pushed, false otherwise
+ // (e.g. prevents hidden files to be included unless explicitly told so)
+ function pushFile(file, query) {
+ // hidden file?
+ if (path.basename(file)[0] === '.') {
+ // not explicitly asking for hidden files?
+ if (!options.all && !(path.basename(query)[0] === '.' && path.basename(query).length > 1))
+ return false;
}
+
+ if (common.platform === 'win')
+ file = file.replace(/\\/g, '/');
+
+ list.push(file);
+ return true;
}
- paths.forEach(function (p) {
- var stat;
+ paths.forEach(function(p) {
+ if (fs.existsSync(p)) {
+ var stats = fs.statSync(p);
+ // Simple file?
+ if (stats.isFile()) {
+ pushFile(p, p);
+ return; // continue
+ }
- try {
- stat = options.link ? fs.statSync(p) : fs.lstatSync(p);
- } catch (e) {
- common.error('no such file or directory: ' + p, 2, { continue: true });
- return;
- }
+ // Simple dir?
+ if (stats.isDirectory()) {
+ // Iterate over p contents
+ fs.readdirSync(p).forEach(function(file) {
+ if (!pushFile(file, p))
+ return;
- // If the stat succeeded
- if (stat.isDirectory() && !options.directory) {
- if (options.recursive) {
- // use glob, because it's simple
- glob.sync(p + globPatternRecursive, { dot: options.all, follow: options.link })
- .forEach(function (item) {
- // Glob pattern returns the directory itself and needs to be filtered out.
- if (path.relative(p, item)) {
- pushFile(item, path.relative(p, item));
- }
- });
- } else if (options.all) {
- // use fs.readdirSync, because it's fast
- fs.readdirSync(p).forEach(function (item) {
- pushFile(path.join(p, item), item);
- });
- } else {
- // use fs.readdirSync and then filter out secret files
- fs.readdirSync(p).forEach(function (item) {
- if (item[0] !== '.') {
- pushFile(path.join(p, item), item);
+ // Recursive?
+ if (options.recursive) {
+ var oldDir = _pwd();
+ _cd('', p);
+ if (fs.statSync(file).isDirectory())
+ list = list.concat(_ls('-R'+(options.all?'A':''), file+'/*'));
+ _cd('', oldDir);
}
});
+ return; // continue
}
- } else {
- pushFile(p, p, stat);
}
+
+ // p does not exist - possible wildcard present
+
+ var basename = path.basename(p);
+ var dirname = path.dirname(p);
+ // Wildcard present on an existing dir? (e.g. '/tmp/*.js')
+ if (basename.search(/\*/) > -1 && fs.existsSync(dirname) && fs.statSync(dirname).isDirectory) {
+ // Escape special regular expression chars
+ var regexp = basename.replace(/(\^|\$|\(|\)|<|>|\[|\]|\{|\}|\.|\+|\?)/g, '\\$1');
+ // Translates wildcard into regex
+ regexp = '^' + regexp.replace(/\*/g, '.*') + '$';
+ // Iterate over directory contents
+ fs.readdirSync(dirname).forEach(function(file) {
+ if (file.match(new RegExp(regexp))) {
+ if (!pushFile(path.normalize(dirname+'/'+file), basename))
+ return;
+
+ // Recursive?
+ if (options.recursive) {
+ var pp = dirname + '/' + file;
+ if (fs.lstatSync(pp).isDirectory())
+ list = list.concat(_ls('-R'+(options.all?'A':''), pp+'/*'));
+ } // recursive
+ } // if file matches
+ }); // forEach
+ return;
+ }
+
+ common.error('no such file or directory: ' + p, true);
});
- // Add methods, to make this more compatible with ShellStrings
return list;
}
-
-function addLsAttributes(pathName, stats) {
- // Note: this object will contain more information than .toString() returns
- stats.name = pathName;
- stats.toString = function () {
- // Return a string resembling unix's `ls -l` format
- return [this.mode, this.nlink, this.uid, this.gid, this.size, this.mtime, this.name].join(' ');
- };
- return stats;
-}
-
module.exports = _ls;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/mkdir.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/mkdir.js b/node_modules/shelljs/src/mkdir.js
index 115f75c..5a7088f 100644
--- a/node_modules/shelljs/src/mkdir.js
+++ b/node_modules/shelljs/src/mkdir.js
@@ -2,23 +2,10 @@ var common = require('./common');
var fs = require('fs');
var path = require('path');
-common.register('mkdir', _mkdir, {
- cmdOptions: {
- 'p': 'fullpath',
- },
-});
-
// Recursively creates 'dir'
function mkdirSyncRecursive(dir) {
var baseDir = path.dirname(dir);
- // Prevents some potential problems arising from malformed UNCs or
- // insufficient permissions.
- /* istanbul ignore next */
- if (baseDir === dir) {
- common.error('dirname() failed: [' + dir + ']');
- }
-
// Base dir exists, no recursion necessary
if (fs.existsSync(baseDir)) {
fs.mkdirSync(dir, parseInt('0777', 8));
@@ -33,11 +20,11 @@ function mkdirSyncRecursive(dir) {
}
//@
-//@ ### mkdir([options,] dir [, dir ...])
-//@ ### mkdir([options,] dir_array)
+//@ ### mkdir([options ,] dir [, dir ...])
+//@ ### mkdir([options ,] dir_array)
//@ Available options:
//@
-//@ + `-p`: full path (will create intermediate dirs if necessary)
+//@ + `p`: full path (will create intermediate dirs if necessary)
//@
//@ Examples:
//@
@@ -48,46 +35,34 @@ function mkdirSyncRecursive(dir) {
//@
//@ Creates directories.
function _mkdir(options, dirs) {
- if (!dirs) common.error('no paths given');
+ options = common.parseOptions(options, {
+ 'p': 'fullpath'
+ });
+ if (!dirs)
+ common.error('no paths given');
- if (typeof dirs === 'string') {
+ if (typeof dirs === 'string')
dirs = [].slice.call(arguments, 1);
- }
// if it's array leave it as it is
- dirs.forEach(function (dir) {
- try {
- fs.lstatSync(dir);
- if (!options.fullpath) {
- common.error('path already exists: ' + dir, { continue: true });
- }
+ dirs.forEach(function(dir) {
+ if (fs.existsSync(dir)) {
+ if (!options.fullpath)
+ common.error('path already exists: ' + dir, true);
return; // skip dir
- } catch (e) {
- // do nothing
}
// Base dir does not exist, and no -p option given
var baseDir = path.dirname(dir);
if (!fs.existsSync(baseDir) && !options.fullpath) {
- common.error('no such file or directory: ' + baseDir, { continue: true });
+ common.error('no such file or directory: ' + baseDir, true);
return; // skip dir
}
- try {
- if (options.fullpath) {
- mkdirSyncRecursive(path.resolve(dir));
- } else {
- fs.mkdirSync(dir, parseInt('0777', 8));
- }
- } catch (e) {
- if (e.code === 'EACCES') {
- common.error('cannot create directory ' + dir + ': Permission denied');
- } else {
- /* istanbul ignore next */
- throw e;
- }
- }
+ if (options.fullpath)
+ mkdirSyncRecursive(dir);
+ else
+ fs.mkdirSync(dir, parseInt('0777', 8));
});
- return '';
} // mkdir
module.exports = _mkdir;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/mv.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/mv.js b/node_modules/shelljs/src/mv.js
index 7fc7cf0..11f9607 100644
--- a/node_modules/shelljs/src/mv.js
+++ b/node_modules/shelljs/src/mv.js
@@ -1,34 +1,28 @@
var fs = require('fs');
var path = require('path');
var common = require('./common');
-var cp = require('./cp');
-var rm = require('./rm');
-
-common.register('mv', _mv, {
- cmdOptions: {
- 'f': '!no_force',
- 'n': 'no_force',
- },
-});
//@
-//@ ### mv([options ,] source [, source ...], dest')
-//@ ### mv([options ,] source_array, dest')
+//@ ### mv(source [, source ...], dest')
+//@ ### mv(source_array, dest')
//@ Available options:
//@
-//@ + `-f`: force (default behavior)
-//@ + `-n`: no-clobber
+//@ + `f`: force
//@
//@ Examples:
//@
//@ ```javascript
-//@ mv('-n', 'file', 'dir/');
+//@ mv('-f', 'file', 'dir/');
//@ mv('file1', 'file2', 'dir/');
//@ mv(['file1', 'file2'], 'dir/'); // same as above
//@ ```
//@
-//@ Moves files.
+//@ Moves files. The wildcard `*` is accepted.
function _mv(options, sources, dest) {
+ options = common.parseOptions(options, {
+ 'f': 'force'
+ });
+
// Get sources, dest
if (arguments.length < 3) {
common.error('missing <source> and/or <dest>');
@@ -37,27 +31,28 @@ function _mv(options, sources, dest) {
dest = arguments[arguments.length - 1];
} else if (typeof sources === 'string') {
sources = [sources];
+ } else if ('length' in sources) {
+ sources = sources; // no-op for array
} else {
- // TODO(nate): figure out if we actually need this line
common.error('invalid arguments');
}
- var exists = fs.existsSync(dest);
- var stats = exists && fs.statSync(dest);
+ sources = common.expand(sources);
+
+ var exists = fs.existsSync(dest),
+ stats = exists && fs.statSync(dest);
// Dest is not existing dir, but multiple sources given
- if ((!exists || !stats.isDirectory()) && sources.length > 1) {
+ if ((!exists || !stats.isDirectory()) && sources.length > 1)
common.error('dest is not a directory (too many sources)');
- }
// Dest is an existing file, but no -f given
- if (exists && stats.isFile() && options.no_force) {
+ if (exists && stats.isFile() && !options.force)
common.error('dest file already exists: ' + dest);
- }
- sources.forEach(function (src) {
+ sources.forEach(function(src) {
if (!fs.existsSync(src)) {
- common.error('no such file or directory: ' + src, { continue: true });
+ common.error('no such file or directory: '+src, true);
return; // skip file
}
@@ -66,34 +61,20 @@ function _mv(options, sources, dest) {
// When copying to '/path/dir':
// thisDest = '/path/dir/file1'
var thisDest = dest;
- if (fs.existsSync(dest) && fs.statSync(dest).isDirectory()) {
+ if (fs.existsSync(dest) && fs.statSync(dest).isDirectory())
thisDest = path.normalize(dest + '/' + path.basename(src));
- }
- if (fs.existsSync(thisDest) && options.no_force) {
- common.error('dest file already exists: ' + thisDest, { continue: true });
+ if (fs.existsSync(thisDest) && !options.force) {
+ common.error('dest file already exists: ' + thisDest, true);
return; // skip file
}
if (path.resolve(src) === path.dirname(path.resolve(thisDest))) {
- common.error('cannot move to self: ' + src, { continue: true });
+ common.error('cannot move to self: '+src, true);
return; // skip file
}
- try {
- fs.renameSync(src, thisDest);
- } catch (e) {
- /* istanbul ignore next */
- if (e.code === 'EXDEV') {
- // If we're trying to `mv` to an external partition, we'll actually need
- // to perform a copy and then clean up the original file. If either the
- // copy or the rm fails with an exception, we should allow this
- // exception to pass up to the top level.
- cp('-r', src, thisDest);
- rm('-rf', src);
- }
- }
+ fs.renameSync(src, thisDest);
}); // forEach(src)
- return '';
} // mv
module.exports = _mv;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/popd.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/popd.js b/node_modules/shelljs/src/popd.js
index d9eac3f..11ea24f 100644
--- a/node_modules/shelljs/src/popd.js
+++ b/node_modules/shelljs/src/popd.js
@@ -1 +1 @@
-// see dirs.js
+// see dirs.js
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/pushd.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/pushd.js b/node_modules/shelljs/src/pushd.js
index d9eac3f..11ea24f 100644
--- a/node_modules/shelljs/src/pushd.js
+++ b/node_modules/shelljs/src/pushd.js
@@ -1 +1 @@
-// see dirs.js
+// see dirs.js
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/pwd.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/pwd.js b/node_modules/shelljs/src/pwd.js
index 3861851..41727bb 100644
--- a/node_modules/shelljs/src/pwd.js
+++ b/node_modules/shelljs/src/pwd.js
@@ -1,15 +1,11 @@
var path = require('path');
var common = require('./common');
-common.register('pwd', _pwd, {
- allowGlobbing: false,
-});
-
//@
//@ ### pwd()
//@ Returns the current directory.
-function _pwd() {
+function _pwd(options) {
var pwd = path.resolve(process.cwd());
- return pwd;
+ return common.ShellString(pwd);
}
module.exports = _pwd;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/rm.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/rm.js b/node_modules/shelljs/src/rm.js
index 5953681..bd608cb 100644
--- a/node_modules/shelljs/src/rm.js
+++ b/node_modules/shelljs/src/rm.js
@@ -1,14 +1,6 @@
var common = require('./common');
var fs = require('fs');
-common.register('rm', _rm, {
- cmdOptions: {
- 'f': 'force',
- 'r': 'recursive',
- 'R': 'recursive',
- },
-});
-
// Recursively removes 'dir'
// Adapted from https://github.com/ryanmcgrath/wrench-js
//
@@ -23,24 +15,32 @@ function rmdirSyncRecursive(dir, force) {
files = fs.readdirSync(dir);
// Loop through and delete everything in the sub-tree after checking it
- for (var i = 0; i < files.length; i++) {
- var file = dir + '/' + files[i];
- var currFile = fs.lstatSync(file);
+ for(var i = 0; i < files.length; i++) {
+ var file = dir + "/" + files[i],
+ currFile = fs.lstatSync(file);
- if (currFile.isDirectory()) { // Recursive function back to the beginning
+ if(currFile.isDirectory()) { // Recursive function back to the beginning
rmdirSyncRecursive(file, force);
- } else { // Assume it's a file - perhaps a try/catch belongs here?
+ }
+
+ else if(currFile.isSymbolicLink()) { // Unlink symlinks
if (force || isWriteable(file)) {
try {
common.unlinkSync(file);
} catch (e) {
- /* istanbul ignore next */
- common.error('could not remove file (code ' + e.code + '): ' + file, {
- continue: true,
- });
+ common.error('could not remove file (code '+e.code+'): ' + file, true);
}
}
}
+
+ else // Assume it's a file - perhaps a try/catch belongs here?
+ if (force || isWriteable(file)) {
+ try {
+ common.unlinkSync(file);
+ } catch (e) {
+ common.error('could not remove file (code '+e.code+'): ' + file, true);
+ }
+ }
}
// Now that we know everything in the sub-tree has been deleted, we can delete the main directory.
@@ -50,19 +50,16 @@ function rmdirSyncRecursive(dir, force) {
try {
// Retry on windows, sometimes it takes a little time before all the files in the directory are gone
var start = Date.now();
-
- // TODO: replace this with a finite loop
- for (;;) {
+ while (true) {
try {
result = fs.rmdirSync(dir);
- if (fs.existsSync(dir)) throw { code: 'EAGAIN' };
+ if (fs.existsSync(dir)) throw { code: "EAGAIN" }
break;
- } catch (er) {
- /* istanbul ignore next */
+ } catch(er) {
// In addition to error codes, also check if the directory still exists and loop again if true
- if (process.platform === 'win32' && (er.code === 'ENOTEMPTY' || er.code === 'EBUSY' || er.code === 'EPERM' || er.code === 'EAGAIN')) {
+ if (process.platform === "win32" && (er.code === "ENOTEMPTY" || er.code === "EBUSY" || er.code === "EPERM" || er.code === "EAGAIN")) {
if (Date.now() - start > 1000) throw er;
- } else if (er.code === 'ENOENT') {
+ } else if (er.code === "ENOENT") {
// Directory did not exist, deletion was successful
break;
} else {
@@ -70,8 +67,8 @@ function rmdirSyncRecursive(dir, force) {
}
}
}
- } catch (e) {
- common.error('could not remove directory (code ' + e.code + '): ' + dir, { continue: true });
+ } catch(e) {
+ common.error('could not remove directory (code '+e.code+'): ' + dir, true);
}
return result;
@@ -84,7 +81,7 @@ function isWriteable(file) {
try {
var __fd = fs.openSync(file, 'a');
fs.closeSync(__fd);
- } catch (e) {
+ } catch(e) {
writePermission = false;
}
@@ -92,8 +89,8 @@ function isWriteable(file) {
}
//@
-//@ ### rm([options,] file [, file ...])
-//@ ### rm([options,] file_array)
+//@ ### rm([options ,] file [, file ...])
+//@ ### rm([options ,] file_array)
//@ Available options:
//@
//@ + `-f`: force
@@ -107,44 +104,60 @@ function isWriteable(file) {
//@ rm(['some_file.txt', 'another_file.txt']); // same as above
//@ ```
//@
-//@ Removes files.
+//@ Removes files. The wildcard `*` is accepted.
function _rm(options, files) {
- if (!files) common.error('no paths given');
+ options = common.parseOptions(options, {
+ 'f': 'force',
+ 'r': 'recursive',
+ 'R': 'recursive'
+ });
+ if (!files)
+ common.error('no paths given');
+
+ if (typeof files === 'string')
+ files = [].slice.call(arguments, 1);
+ // if it's array leave it as it is
- // Convert to array
- files = [].slice.call(arguments, 1);
+ files = common.expand(files);
- files.forEach(function (file) {
- var stats;
- try {
- stats = fs.lstatSync(file); // test for existence
- } catch (e) {
+ files.forEach(function(file) {
+ if (!fs.existsSync(file)) {
// Path does not exist, no force flag given
- if (!options.force) {
- common.error('no such file or directory: ' + file, { continue: true });
- }
+ if (!options.force)
+ common.error('no such file or directory: '+file, true);
+
return; // skip file
}
// If here, path exists
- if (stats.isFile()) {
- if (options.force || isWriteable(file)) {
- // -f was passed, or file is writable, so it can be removed
+
+ var stats = fs.lstatSync(file);
+ if (stats.isFile() || stats.isSymbolicLink()) {
+
+ // Do not check for file writing permissions
+ if (options.force) {
common.unlinkSync(file);
- } else {
- common.error('permission denied: ' + file, { continue: true });
- }
- } else if (stats.isDirectory()) {
- if (options.recursive) {
- // -r was passed, so directory can be removed
- rmdirSyncRecursive(file, options.force);
- } else {
- common.error('path is a directory', { continue: true });
+ return;
}
- } else if (stats.isSymbolicLink() || stats.isFIFO()) {
- common.unlinkSync(file);
+
+ if (isWriteable(file))
+ common.unlinkSync(file);
+ else
+ common.error('permission denied: '+file, true);
+
+ return;
+ } // simple file
+
+ // Path is an existing directory, but no -r flag given
+ if (stats.isDirectory() && !options.recursive) {
+ common.error('path is a directory', true);
+ return; // skip path
+ }
+
+ // Recursively remove existing directory
+ if (stats.isDirectory() && options.recursive) {
+ rmdirSyncRecursive(file, options.force);
}
}); // forEach(file)
- return '';
} // rm
module.exports = _rm;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/sed.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/sed.js b/node_modules/shelljs/src/sed.js
index dfdc0a7..65f7cb4 100644
--- a/node_modules/shelljs/src/sed.js
+++ b/node_modules/shelljs/src/sed.js
@@ -1,17 +1,8 @@
var common = require('./common');
var fs = require('fs');
-common.register('sed', _sed, {
- globStart: 3, // don't glob-expand regexes
- canReceivePipe: true,
- cmdOptions: {
- 'i': 'inplace',
- },
-});
-
//@
-//@ ### sed([options,] search_regex, replacement, file [, file ...])
-//@ ### sed([options,] search_regex, replacement, file_array)
+//@ ### sed([options ,] search_regex, replacement, file)
//@ Available options:
//@
//@ + `-i`: Replace contents of 'file' in-place. _Note that no backups will be created!_
@@ -23,64 +14,30 @@ common.register('sed', _sed, {
//@ sed(/.*DELETE_THIS_LINE.*\n/, '', 'source.js');
//@ ```
//@
-//@ Reads an input string from `files` and performs a JavaScript `replace()` on the input
+//@ Reads an input string from `file` and performs a JavaScript `replace()` on the input
//@ using the given search regex and replacement string or function. Returns the new string after replacement.
-//@
-//@ Note:
-//@
-//@ Like unix `sed`, ShellJS `sed` supports capture groups. Capture groups are specified
-//@ using the `$n` syntax:
-//@
-//@ ```javascript
-//@ sed(/(\w+)\s(\w+)/, '$2, $1', 'file.txt');
-//@ ```
-function _sed(options, regex, replacement, files) {
- // Check if this is coming from a pipe
- var pipe = common.readFromPipe();
-
- if (typeof replacement !== 'string' && typeof replacement !== 'function') {
- if (typeof replacement === 'number') {
- replacement = replacement.toString(); // fallback
- } else {
- common.error('invalid replacement string');
- }
- }
-
- // Convert all search strings to RegExp
- if (typeof regex === 'string') {
- regex = RegExp(regex);
- }
-
- if (!files && !pipe) {
- common.error('no files given');
- }
-
- files = [].slice.call(arguments, 3);
-
- if (pipe) {
- files.unshift('-');
- }
+function _sed(options, regex, replacement, file) {
+ options = common.parseOptions(options, {
+ 'i': 'inplace'
+ });
- var sed = [];
- files.forEach(function (file) {
- if (!fs.existsSync(file) && file !== '-') {
- common.error('no such file or directory: ' + file, 2, { continue: true });
- return;
- }
+ if (typeof replacement === 'string' || typeof replacement === 'function')
+ replacement = replacement; // no-op
+ else if (typeof replacement === 'number')
+ replacement = replacement.toString(); // fallback
+ else
+ common.error('invalid replacement string');
- var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8');
- var lines = contents.split(/\r*\n/);
- var result = lines.map(function (line) {
- return line.replace(regex, replacement);
- }).join('\n');
+ if (!file)
+ common.error('no file given');
- sed.push(result);
+ if (!fs.existsSync(file))
+ common.error('no such file or directory: ' + file);
- if (options.inplace) {
- fs.writeFileSync(file, result, 'utf8');
- }
- });
+ var result = fs.readFileSync(file, 'utf8').replace(regex, replacement);
+ if (options.inplace)
+ fs.writeFileSync(file, result, 'utf8');
- return sed.join('\n');
+ return common.ShellString(result);
}
module.exports = _sed;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/set.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/set.js b/node_modules/shelljs/src/set.js
deleted file mode 100644
index 238e23e..0000000
--- a/node_modules/shelljs/src/set.js
+++ /dev/null
@@ -1,55 +0,0 @@
-var common = require('./common');
-
-common.register('set', _set, {
- allowGlobbing: false,
- wrapOutput: false,
-});
-
-//@
-//@ ### set(options)
-//@ Available options:
-//@
-//@ + `+/-e`: exit upon error (`config.fatal`)
-//@ + `+/-v`: verbose: show all commands (`config.verbose`)
-//@ + `+/-f`: disable filename expansion (globbing)
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ set('-e'); // exit upon first error
-//@ set('+e'); // this undoes a "set('-e')"
-//@ ```
-//@
-//@ Sets global configuration variables
-function _set(options) {
- if (!options) {
- var args = [].slice.call(arguments, 0);
- if (args.length < 2) common.error('must provide an argument');
- options = args[1];
- }
- var negate = (options[0] === '+');
- if (negate) {
- options = '-' + options.slice(1); // parseOptions needs a '-' prefix
- }
- options = common.parseOptions(options, {
- 'e': 'fatal',
- 'v': 'verbose',
- 'f': 'noglob',
- });
-
- if (negate) {
- Object.keys(options).forEach(function (key) {
- options[key] = !options[key];
- });
- }
-
- Object.keys(options).forEach(function (key) {
- // Only change the global config if `negate` is false and the option is true
- // or if `negate` is true and the option is false (aka negate !== option)
- if (negate !== options[key]) {
- common.config[key] = options[key];
- }
- });
- return;
-}
-module.exports = _set;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/tempdir.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/tempdir.js b/node_modules/shelljs/src/tempdir.js
index a2d15be..45953c2 100644
--- a/node_modules/shelljs/src/tempdir.js
+++ b/node_modules/shelljs/src/tempdir.js
@@ -2,24 +2,20 @@ var common = require('./common');
var os = require('os');
var fs = require('fs');
-common.register('tempdir', _tempDir, {
- allowGlobbing: false,
- wrapOutput: false,
-});
-
// Returns false if 'dir' is not a writeable directory, 'dir' otherwise
function writeableDir(dir) {
- if (!dir || !fs.existsSync(dir)) return false;
+ if (!dir || !fs.existsSync(dir))
+ return false;
- if (!fs.statSync(dir).isDirectory()) return false;
+ if (!fs.statSync(dir).isDirectory())
+ return false;
- var testFile = dir + '/' + common.randomFileName();
+ var testFile = dir+'/'+common.randomFileName();
try {
fs.writeFileSync(testFile, ' ');
common.unlinkSync(testFile);
return dir;
} catch (e) {
- /* istanbul ignore next */
return false;
}
}
@@ -38,14 +34,14 @@ function writeableDir(dir) {
//@ Follows Python's [tempfile algorithm](http://docs.python.org/library/tempfile.html#tempfile.tempdir).
function _tempDir() {
var state = common.state;
- if (state.tempDir) return state.tempDir; // from cache
-
- state.tempDir = writeableDir(os.tmpdir && os.tmpdir()) || // node 0.10+
- writeableDir(os.tmpDir && os.tmpDir()) || // node 0.8+
- writeableDir(process.env.TMPDIR) ||
- writeableDir(process.env.TEMP) ||
- writeableDir(process.env.TMP) ||
- writeableDir(process.env.Wimp$ScrapDir) || // RiscOS
+ if (state.tempDir)
+ return state.tempDir; // from cache
+
+ state.tempDir = writeableDir(os.tempDir && os.tempDir()) || // node 0.8+
+ writeableDir(process.env['TMPDIR']) ||
+ writeableDir(process.env['TEMP']) ||
+ writeableDir(process.env['TMP']) ||
+ writeableDir(process.env['Wimp$ScrapDir']) || // RiscOS
writeableDir('C:\\TEMP') || // Windows
writeableDir('C:\\TMP') || // Windows
writeableDir('\\TEMP') || // Windows
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/test.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/test.js b/node_modules/shelljs/src/test.js
index d3d9c07..8a4ac7d 100644
--- a/node_modules/shelljs/src/test.js
+++ b/node_modules/shelljs/src/test.js
@@ -1,22 +1,6 @@
var common = require('./common');
var fs = require('fs');
-common.register('test', _test, {
- cmdOptions: {
- 'b': 'block',
- 'c': 'character',
- 'd': 'directory',
- 'e': 'exists',
- 'f': 'file',
- 'L': 'link',
- 'p': 'pipe',
- 'S': 'socket',
- },
- wrapOutput: false,
- allowGlobbing: false,
-});
-
-
//@
//@ ### test(expression)
//@ Available expression primaries:
@@ -26,7 +10,7 @@ common.register('test', _test, {
//@ + `'-d', 'path'`: true if path is a directory
//@ + `'-e', 'path'`: true if path exists
//@ + `'-f', 'path'`: true if path is a regular file
-//@ + `'-L', 'path'`: true if path is a symbolic link
+//@ + `'-L', 'path'`: true if path is a symboilc link
//@ + `'-p', 'path'`: true if path is a pipe (FIFO)
//@ + `'-S', 'path'`: true if path is a socket
//@
@@ -39,46 +23,63 @@ common.register('test', _test, {
//@
//@ Evaluates expression using the available primaries and returns corresponding value.
function _test(options, path) {
- if (!path) common.error('no path given');
+ if (!path)
+ common.error('no path given');
+
+ // hack - only works with unary primaries
+ options = common.parseOptions(options, {
+ 'b': 'block',
+ 'c': 'character',
+ 'd': 'directory',
+ 'e': 'exists',
+ 'f': 'file',
+ 'L': 'link',
+ 'p': 'pipe',
+ 'S': 'socket'
+ });
var canInterpret = false;
- Object.keys(options).forEach(function (key) {
+ for (var key in options)
if (options[key] === true) {
canInterpret = true;
+ break;
}
- });
- if (!canInterpret) common.error('could not interpret expression');
+ if (!canInterpret)
+ common.error('could not interpret expression');
if (options.link) {
try {
return fs.lstatSync(path).isSymbolicLink();
- } catch (e) {
+ } catch(e) {
return false;
}
}
- if (!fs.existsSync(path)) return false;
+ if (!fs.existsSync(path))
+ return false;
- if (options.exists) return true;
+ if (options.exists)
+ return true;
var stats = fs.statSync(path);
- if (options.block) return stats.isBlockDevice();
-
- if (options.character) return stats.isCharacterDevice();
+ if (options.block)
+ return stats.isBlockDevice();
- if (options.directory) return stats.isDirectory();
+ if (options.character)
+ return stats.isCharacterDevice();
- if (options.file) return stats.isFile();
+ if (options.directory)
+ return stats.isDirectory();
- /* istanbul ignore next */
- if (options.pipe) return stats.isFIFO();
+ if (options.file)
+ return stats.isFile();
- /* istanbul ignore next */
- if (options.socket) return stats.isSocket();
+ if (options.pipe)
+ return stats.isFIFO();
- /* istanbul ignore next */
- return false; // fallback
+ if (options.socket)
+ return stats.isSocket();
} // test
module.exports = _test;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/to.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/to.js b/node_modules/shelljs/src/to.js
index d3d9e37..f029999 100644
--- a/node_modules/shelljs/src/to.js
+++ b/node_modules/shelljs/src/to.js
@@ -2,13 +2,8 @@ var common = require('./common');
var fs = require('fs');
var path = require('path');
-common.register('to', _to, {
- pipeOnly: true,
- wrapOutput: false,
-});
-
//@
-//@ ### ShellString.prototype.to(file)
+//@ ### 'string'.to(file)
//@
//@ Examples:
//@
@@ -16,22 +11,19 @@ common.register('to', _to, {
//@ cat('input.txt').to('output.txt');
//@ ```
//@
-//@ Analogous to the redirection operator `>` in Unix, but works with
-//@ ShellStrings (such as those returned by `cat`, `grep`, etc). _Like Unix
-//@ redirections, `to()` will overwrite any existing file!_
+//@ Analogous to the redirection operator `>` in Unix, but works with JavaScript strings (such as
+//@ those returned by `cat`, `grep`, etc). _Like Unix redirections, `to()` will overwrite any existing file!_
function _to(options, file) {
- if (!file) common.error('wrong arguments');
+ if (!file)
+ common.error('wrong arguments');
- if (!fs.existsSync(path.dirname(file))) {
- common.error('no such file or directory: ' + path.dirname(file));
- }
+ if (!fs.existsSync( path.dirname(file) ))
+ common.error('no such file or directory: ' + path.dirname(file));
try {
- fs.writeFileSync(file, this.stdout || this.toString(), 'utf8');
- return this;
- } catch (e) {
- /* istanbul ignore next */
- common.error('could not write to file (code ' + e.code + '): ' + file, { continue: true });
+ fs.writeFileSync(file, this.toString(), 'utf8');
+ } catch(e) {
+ common.error('could not write to file (code '+e.code+'): '+file, true);
}
}
module.exports = _to;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/toEnd.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/toEnd.js b/node_modules/shelljs/src/toEnd.js
index dc165fe..f6d099d 100644
--- a/node_modules/shelljs/src/toEnd.js
+++ b/node_modules/shelljs/src/toEnd.js
@@ -2,13 +2,8 @@ var common = require('./common');
var fs = require('fs');
var path = require('path');
-common.register('toEnd', _toEnd, {
- pipeOnly: true,
- wrapOutput: false,
-});
-
//@
-//@ ### ShellString.prototype.toEnd(file)
+//@ ### 'string'.toEnd(file)
//@
//@ Examples:
//@
@@ -16,21 +11,19 @@ common.register('toEnd', _toEnd, {
//@ cat('input.txt').toEnd('output.txt');
//@ ```
//@
-//@ Analogous to the redirect-and-append operator `>>` in Unix, but works with
-//@ ShellStrings (such as those returned by `cat`, `grep`, etc).
+//@ Analogous to the redirect-and-append operator `>>` in Unix, but works with JavaScript strings (such as
+//@ those returned by `cat`, `grep`, etc).
function _toEnd(options, file) {
- if (!file) common.error('wrong arguments');
+ if (!file)
+ common.error('wrong arguments');
- if (!fs.existsSync(path.dirname(file))) {
- common.error('no such file or directory: ' + path.dirname(file));
- }
+ if (!fs.existsSync( path.dirname(file) ))
+ common.error('no such file or directory: ' + path.dirname(file));
try {
- fs.appendFileSync(file, this.stdout || this.toString(), 'utf8');
- return this;
- } catch (e) {
- /* istanbul ignore next */
- common.error('could not append to file (code ' + e.code + '): ' + file, { continue: true });
+ fs.appendFileSync(file, this.toString(), 'utf8');
+ } catch(e) {
+ common.error('could not append to file (code '+e.code+'): '+file, true);
}
}
module.exports = _toEnd;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/touch.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/touch.js b/node_modules/shelljs/src/touch.js
deleted file mode 100644
index b672b2d..0000000
--- a/node_modules/shelljs/src/touch.js
+++ /dev/null
@@ -1,110 +0,0 @@
-var common = require('./common');
-var fs = require('fs');
-
-common.register('touch', _touch, {
- cmdOptions: {
- 'a': 'atime_only',
- 'c': 'no_create',
- 'd': 'date',
- 'm': 'mtime_only',
- 'r': 'reference',
- },
-});
-
-//@
-//@ ### touch([options,] file [, file ...])
-//@ ### touch([options,] file_array)
-//@ Available options:
-//@
-//@ + `-a`: Change only the access time
-//@ + `-c`: Do not create any files
-//@ + `-m`: Change only the modification time
-//@ + `-d DATE`: Parse DATE and use it instead of current time
-//@ + `-r FILE`: Use FILE's times instead of current time
-//@
-//@ Examples:
-//@
-//@ ```javascript
-//@ touch('source.js');
-//@ touch('-c', '/path/to/some/dir/source.js');
-//@ touch({ '-r': FILE }, '/path/to/some/dir/source.js');
-//@ ```
-//@
-//@ Update the access and modification times of each FILE to the current time.
-//@ A FILE argument that does not exist is created empty, unless -c is supplied.
-//@ This is a partial implementation of *[touch(1)](http://linux.die.net/man/1/touch)*.
-function _touch(opts, files) {
- if (!files) {
- common.error('no files given');
- } else if (typeof files === 'string') {
- files = [].slice.call(arguments, 1);
- } else {
- common.error('file arg should be a string file path or an Array of string file paths');
- }
-
- files.forEach(function (f) {
- touchFile(opts, f);
- });
- return '';
-}
-
-function touchFile(opts, file) {
- var stat = tryStatFile(file);
-
- if (stat && stat.isDirectory()) {
- // don't error just exit
- return;
- }
-
- // if the file doesn't already exist and the user has specified --no-create then
- // this script is finished
- if (!stat && opts.no_create) {
- return;
- }
-
- // open the file and then close it. this will create it if it doesn't exist but will
- // not truncate the file
- fs.closeSync(fs.openSync(file, 'a'));
-
- //
- // Set timestamps
- //
-
- // setup some defaults
- var now = new Date();
- var mtime = opts.date || now;
- var atime = opts.date || now;
-
- // use reference file
- if (opts.reference) {
- var refStat = tryStatFile(opts.reference);
- if (!refStat) {
- common.error('failed to get attributess of ' + opts.reference);
- }
- mtime = refStat.mtime;
- atime = refStat.atime;
- } else if (opts.date) {
- mtime = opts.date;
- atime = opts.date;
- }
-
- if (opts.atime_only && opts.mtime_only) {
- // keep the new values of mtime and atime like GNU
- } else if (opts.atime_only) {
- mtime = stat.mtime;
- } else if (opts.mtime_only) {
- atime = stat.atime;
- }
-
- fs.utimesSync(file, atime, mtime);
-}
-
-module.exports = _touch;
-
-function tryStatFile(filePath) {
- try {
- return fs.statSync(filePath);
- } catch (e) {
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/node_modules/shelljs/src/which.js
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/src/which.js b/node_modules/shelljs/src/which.js
index 03db57b..2822ecf 100644
--- a/node_modules/shelljs/src/which.js
+++ b/node_modules/shelljs/src/which.js
@@ -2,24 +2,21 @@ var common = require('./common');
var fs = require('fs');
var path = require('path');
-common.register('which', _which, {
- allowGlobbing: false,
- cmdOptions: {
- 'a': 'all',
- },
-});
-
-// XP's system default value for PATHEXT system variable, just in case it's not
-// set on Windows.
-var XP_DEFAULT_PATHEXT = '.com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh';
-
// Cross-platform method for splitting environment PATH variables
function splitPath(p) {
- return p ? p.split(path.delimiter) : [];
+ for (i=1;i<2;i++) {}
+
+ if (!p)
+ return [];
+
+ if (common.platform === 'win')
+ return p.split(';');
+ else
+ return p.split(':');
}
-function checkPath(pathName) {
- return fs.existsSync(pathName) && !fs.statSync(pathName).isDirectory();
+function checkPath(path) {
+ return fs.existsSync(path) && fs.statSync(path).isDirectory() == false;
}
//@
@@ -31,68 +28,56 @@ function checkPath(pathName) {
//@ var nodeExec = which('node');
//@ ```
//@
-//@ Searches for `command` in the system's PATH. On Windows, this uses the
-//@ `PATHEXT` variable to append the extension if it's not already executable.
+//@ Searches for `command` in the system's PATH. On Windows looks for `.exe`, `.cmd`, and `.bat` extensions.
//@ Returns string containing the absolute path to the command.
function _which(options, cmd) {
- if (!cmd) common.error('must specify command');
+ if (!cmd)
+ common.error('must specify command');
- var pathEnv = process.env.path || process.env.Path || process.env.PATH;
- var pathArray = splitPath(pathEnv);
-
- var queryMatches = [];
+ var pathEnv = process.env.path || process.env.Path || process.env.PATH,
+ pathArray = splitPath(pathEnv),
+ where = null;
// No relative/absolute paths provided?
- if (cmd.indexOf('/') === -1) {
- // Assume that there are no extensions to append to queries (this is the
- // case for unix)
- var pathExtArray = [''];
- if (common.platform === 'win') {
- // In case the PATHEXT variable is somehow not set (e.g.
- // child_process.spawn with an empty environment), use the XP default.
- var pathExtEnv = process.env.PATHEXT || XP_DEFAULT_PATHEXT;
- pathExtArray = splitPath(pathExtEnv.toUpperCase());
- }
-
+ if (cmd.search(/\//) === -1) {
// Search for command in PATH
- for (var k = 0; k < pathArray.length; k++) {
- // already found it
- if (queryMatches.length > 0 && !options.all) break;
+ pathArray.forEach(function(dir) {
+ if (where)
+ return; // already found it
- var attempt = path.resolve(pathArray[k], cmd);
-
- if (common.platform === 'win') {
- attempt = attempt.toUpperCase();
+ var attempt = path.resolve(dir + '/' + cmd);
+ if (checkPath(attempt)) {
+ where = attempt;
+ return;
}
- var match = attempt.match(/\.[^<>:"/\|?*.]+$/);
- if (match && pathExtArray.indexOf(match[0]) >= 0) { // this is Windows-only
- // The user typed a query with the file extension, like
- // `which('node.exe')`
+ if (common.platform === 'win') {
+ var baseAttempt = attempt;
+ attempt = baseAttempt + '.exe';
if (checkPath(attempt)) {
- queryMatches.push(attempt);
- break;
+ where = attempt;
+ return;
}
- } else { // All-platforms
- // Cycle through the PATHEXT array, and check each extension
- // Note: the array is always [''] on Unix
- for (var i = 0; i < pathExtArray.length; i++) {
- var ext = pathExtArray[i];
- var newAttempt = attempt + ext;
- if (checkPath(newAttempt)) {
- queryMatches.push(newAttempt);
- break;
- }
+ attempt = baseAttempt + '.cmd';
+ if (checkPath(attempt)) {
+ where = attempt;
+ return;
}
- }
- }
- } else if (checkPath(cmd)) { // a valid absolute or relative path
- queryMatches.push(path.resolve(cmd));
+ attempt = baseAttempt + '.bat';
+ if (checkPath(attempt)) {
+ where = attempt;
+ return;
+ }
+ } // if 'win'
+ });
}
- if (queryMatches.length > 0) {
- return options.all ? queryMatches : queryMatches[0];
- }
- return options.all ? [] : null;
+ // Command not found anywhere?
+ if (!checkPath(cmd) && !where)
+ return null;
+
+ where = where || path.resolve(cmd);
+
+ return common.ShellString(where);
}
module.exports = _which;
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/de5c08a3/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index a7ce43c..7e805b1 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,7 @@
],
"scripts": {
"jshint": "jshint bin && jshint spec",
- "jasmine": "jasmine --captureExceptions --color",
+ "jasmine": "jasmine",
"test": "npm run jshint && npm run jasmine"
},
"dependencies": {
@@ -26,7 +26,6 @@
"cordova-common": "^2.0.1",
"cordova-serve": "^1.0.0",
"nopt": "^3.0.6",
- "q": "^1.4.1",
"shelljs": "^0.5.3"
},
"devDependencies": {
@@ -38,7 +37,6 @@
"adm-zip",
"cordova-serve",
"nopt",
- "q",
"shelljs"
],
"author": "Apache Software Foundation",
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[04/25] cordova-browser git commit: hooking up run
Posted by pu...@apache.org.
hooking up run
Project: http://git-wip-us.apache.org/repos/asf/cordova-browser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-browser/commit/6281ea5a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-browser/tree/6281ea5a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-browser/diff/6281ea5a
Branch: refs/heads/master
Commit: 6281ea5af1a2c99a0fdc12356b01c36abc33c720
Parents: 3b4a52f
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Wed Apr 12 23:34:46 2017 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Wed Apr 12 23:34:46 2017 -0700
----------------------------------------------------------------------
bin/template/cordova/Api.js | 4 +-
bin/template/cordova/lib/run.js | 64 +++++++++++++++++++++++
bin/template/cordova/run | 25 ++-------
spec/projectApi.spec.js | 11 ++--
tests/spec/create.spec.js | 99 ------------------------------------
5 files changed, 78 insertions(+), 125 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/6281ea5a/bin/template/cordova/Api.js
----------------------------------------------------------------------
diff --git a/bin/template/cordova/Api.js b/bin/template/cordova/Api.js
index b137606..80f79ff 100644
--- a/bin/template/cordova/Api.js
+++ b/bin/template/cordova/Api.js
@@ -121,11 +121,11 @@ Api.prototype.build = function (buildOptions) {
};
Api.prototype.run = function(runOptions) {
-
+ return require('./lib/run').run(runOptions);
};
Api.prototype.clean = function(cleanOptions) {
- return require('./lib/clean').run();
+ return require('./lib/clean').run(cleanOptions);
};
Api.prototype.requirements = function() {
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/6281ea5a/bin/template/cordova/lib/run.js
----------------------------------------------------------------------
diff --git a/bin/template/cordova/lib/run.js b/bin/template/cordova/lib/run.js
new file mode 100644
index 0000000..083178f
--- /dev/null
+++ b/bin/template/cordova/lib/run.js
@@ -0,0 +1,64 @@
+#!/usr/bin/env node
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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'),
+ url = require('url'),
+ cordovaServe = require('cordova-serve');
+
+module.exports.run = function(args) {
+ // defaults
+ args.port = args.port || 8000;
+ args.target = args.target || "chrome"; // make default the system browser
+
+ var root = path.join(__dirname, '../');
+ var configFilePath = path.resolve(path.join(root, 'config.xml'));
+ var startPage;
+ if(fs.existsSync(configFilePath)) {
+ var configXML = fs.readFileSync(configFilePath, 'utf8');
+ // pull out <content src='SOME_URL'/>
+ startPage = /<content[\s]+?src\s*=\s*"(.*?)"/i.exec(configXML);
+ }
+
+
+
+
+ var server = cordovaServe();
+
+ server.servePlatform('browser', {port: args.port, noServerInfo: true})
+ .then(function () {
+ if(startPage == null) {
+ startPage = 'index.html';
+ }
+ else {
+ startPage = startPage[1];
+ }
+ var projectUrl = url.resolve('http://localhost:' + server.port + '/', startPage);
+ console.log('startPage = ' + startPage);
+ console.log('Static file server running @ ' + projectUrl + '\nCTRL + C to shut down');
+ return cordovaServe.launchBrowser({target: args.target, url: projectUrl});
+ }).catch(function (error) {
+ console.log(error.message || error.toString());
+ if (server.server) {
+ server.server.close();
+ }
+ });
+};
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/6281ea5a/bin/template/cordova/run
----------------------------------------------------------------------
diff --git a/bin/template/cordova/run b/bin/template/cordova/run
index 29c73bc..b41e299 100755
--- a/bin/template/cordova/run
+++ b/bin/template/cordova/run
@@ -23,6 +23,7 @@ var fs = require('fs'),
path = require('path'),
nopt = require('nopt'),
url = require('url'),
+ runForrest = require('./lib/run'),
cordovaServe = require('cordova-serve');
var args = process.argv;
@@ -34,27 +35,9 @@ function start(argv) {
if(args.help) {
help();
}
-
- // defaults
- args.port = args.port || 8000;
- args.target = args.target || "chrome"; // make default the system browser
-
- var root = path.join(__dirname, '../'),
- configFile = path.resolve(path.join(root, 'config.xml')),
- configXML = fs.readFileSync(configFile, 'utf8'),
- sourceFile = /<content[\s]+?src\s*=\s*"(.*?)"/i.exec(configXML);
-
- var server = cordovaServe(); // Who wrote this? JavaScript much?
- server.servePlatform('browser', {port: args.port, noServerInfo: true}).then(function () {
- var projectUrl = url.resolve('http://localhost:' + server.port + '/', sourceFile ? sourceFile[1] : 'index.html');
- console.log('Static file server running @ ' + projectUrl + '\nCTRL + C to shut down');
- return cordovaServe.launchBrowser({target: args.target, url: projectUrl});
- }).catch(function (error) {
- console.log(error.message || error.toString());
- if (server.server) {
- server.server.close();
- }
- });
+ else {
+ return runForrest.run(args);
+ }
}
function help() {
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/6281ea5a/spec/projectApi.spec.js
----------------------------------------------------------------------
diff --git a/spec/projectApi.spec.js b/spec/projectApi.spec.js
index d71a961..cbe56fc 100644
--- a/spec/projectApi.spec.js
+++ b/spec/projectApi.spec.js
@@ -17,7 +17,11 @@
under the License.
*/
-var Api = require("../bin/template/cordova/Api");
+var Api = require('../bin/template/cordova/Api');
+var shell = require('shelljs');
+var fs = require('fs');
+var path = require('path');
+var tmpDir = path.join(__dirname, './temp');
describe('can get the Api', function() {
@@ -30,16 +34,17 @@ describe('can get the Api', function() {
expect(typeof Api.createPlatform).toBe('function');
// TODO: make this do something real
- var promise = Api.createPlatform("../tmp");
+ var promise = Api.createPlatform(tmpDir);
expect(promise).toBeDefined();
expect(promise.then).toBeDefined();
promise.then(function(res) {
console.log('result = ' + res);
- console.log("spec-success");
+ shell.rm('-rf', tmpDir);
done();
},
function(err) {
console.log("spec-error " + err);
+ shell.rm('-rf', tmpDir);
done();
});
});
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/6281ea5a/tests/spec/create.spec.js
----------------------------------------------------------------------
diff --git a/tests/spec/create.spec.js b/tests/spec/create.spec.js
deleted file mode 100644
index 66b84d2..0000000
--- a/tests/spec/create.spec.js
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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 shell = require('shelljs'),
- spec = __dirname,
- path = require('path'),
- util = require('util');
-
- var cordova_bin = path.join(spec, '../..', 'bin');
- var tmp = require('tmp').dirSync().name;
-
-function createAndBuild(projectname, projectid) {
- var return_code = 0;
- var command;
-
- // remove existing folder
- command = path.join(tmp, projectname);
- shell.rm('-rf', command);
-
- // create the project
- command = util.format('"%s/create" "%s/%s" %s "%s"', cordova_bin, tmp, projectname, projectid, projectname);
- shell.echo(command);
- return_code = shell.exec(command).code;
- expect(return_code).toBe(0);
-
- // build the project
- command = util.format('"%s/cordova/build"', path.join(tmp, projectname));
- shell.echo(command);
- return_code = shell.exec(command, { silent: true }).code;
- expect(return_code).toBe(0);
-
- // clean-up
- command = path.join(tmp, projectname);
- shell.rm('-rf', command);
-}
-
-
-describe('create', function() {
-
- it('create project with ascii name, no spaces', function() {
- var projectname = 'testcreate';
- var projectid = 'com.test.app1';
-
- createAndBuild(projectname, projectid);
- });
-
- it('create project with ascii name, and spaces', function() {
- var projectname = 'test create';
- var projectid = 'com.test.app2';
-
- createAndBuild(projectname, projectid);
- });
-
- it('create project with unicode name, no spaces', function() {
- var projectname = '応応応応用用用用';
- var projectid = 'com.test.app3';
-
- createAndBuild(projectname, projectid);
- });
-
- it('create project with unicode name, and spaces', function() {
- var projectname = '応応応応 用用用用';
- var projectid = 'com.test.app4';
-
- createAndBuild(projectname, projectid);
- });
-
- it('create project with ascii+unicode name, no spaces', function() {
- var projectname = '応応応応hello用用用用';
- var projectid = 'com.test.app5';
-
- createAndBuild(projectname, projectid);
- });
-
- it('create project with ascii+unicode name, and spaces', function() {
- var projectname = '応応応応 hello 用用用用';
- var projectid = 'com.test.app6';
-
- createAndBuild(projectname, projectid);
- });
-
-});
-
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[09/25] cordova-browser git commit: copy template www contents
Posted by pu...@apache.org.
copy template www contents
Project: http://git-wip-us.apache.org/repos/asf/cordova-browser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-browser/commit/22b8a253
Tree: http://git-wip-us.apache.org/repos/asf/cordova-browser/tree/22b8a253
Diff: http://git-wip-us.apache.org/repos/asf/cordova-browser/diff/22b8a253
Branch: refs/heads/master
Commit: 22b8a2532076095e3da01133003e27c4cbc8836b
Parents: 4a07e78
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu Apr 13 18:03:34 2017 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu Apr 13 18:03:34 2017 -0700
----------------------------------------------------------------------
bin/lib/create.js | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/22b8a253/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/bin/lib/create.js b/bin/lib/create.js
index d1000ed..fcbfc7f 100644
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -63,9 +63,6 @@ module.exports.createProject = function(project_path,package_name,project_name){
return;
}
- //copy template directory ( recursive )
- //shell.cp('-r', path.join(ROOT, 'bin/templates/project/www'), project_path);
-
//create cordova/lib if it does not exist yet
if (!fs.existsSync(path.join(project_path,'cordova/lib'))) {
shell.mkdir('-p', path.join(project_path,'cordova/lib'));
@@ -78,10 +75,14 @@ module.exports.createProject = function(project_path,package_name,project_name){
shell.cp( path.join(ROOT, 'bin/lib/check_reqs.js'), path.join(project_path,'cordova/lib'));
//copy cordova js file
- shell.cp('-r', path.join(ROOT, 'cordova-lib', 'cordova.js'), path.join(project_path,'www'));
+ shell.cp('-r', path.join(ROOT, 'cordova-lib', 'cordova.js'),
+ path.join(project_path,'www'));
+ //copy template directory ( recursive )
+ shell.cp('-r', path.join(ROOT, 'bin/template/www'), project_path);
//copy cordova-js-src directory
- shell.cp('-rf', path.join(ROOT, 'cordova-js-src'), path.join(project_path, 'platform_www'));
+ shell.cp('-rf', path.join(ROOT, 'cordova-js-src'),
+ path.join(project_path, 'platform_www'));
//copy cordova directory
shell.cp('-r', path.join(ROOT, 'bin/template/cordova'), project_path);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[18/25] cordova-browser git commit: clean up,
get package name from config, cordova.js was getting overwritten
Posted by pu...@apache.org.
clean up, get package name from config, cordova.js was getting overwritten
Project: http://git-wip-us.apache.org/repos/asf/cordova-browser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-browser/commit/62e0b067
Tree: http://git-wip-us.apache.org/repos/asf/cordova-browser/tree/62e0b067
Diff: http://git-wip-us.apache.org/repos/asf/cordova-browser/diff/62e0b067
Branch: refs/heads/master
Commit: 62e0b0674cdd8b0f4399d830f694fbbc86c83b9e
Parents: 4345045
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Fri May 5 01:02:20 2017 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Fri May 5 01:02:20 2017 -0700
----------------------------------------------------------------------
bin/lib/create.js | 23 ++++++-------
bin/template/cordova/Api.js | 30 ++++++-----------
bin/template/cordova/browser_handler.js | 18 ++++++++---
bin/template/cordova/browser_parser.js | 48 +++++++++++-----------------
4 files changed, 54 insertions(+), 65 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/62e0b067/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/bin/lib/create.js b/bin/lib/create.js
index fcbfc7f..33a31a1 100644
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -63,28 +63,29 @@ module.exports.createProject = function(project_path,package_name,project_name){
return;
}
- //create cordova/lib if it does not exist yet
- if (!fs.existsSync(path.join(project_path,'cordova/lib'))) {
- shell.mkdir('-p', path.join(project_path,'cordova/lib'));
- }
+ //copy template/cordova directory ( recursive )
+ shell.cp('-r', path.join(ROOT, 'bin/template/cordova'), project_path);
+
+ //copy template/www directory ( recursive )
+ shell.cp('-r', path.join(ROOT, 'bin/template/www'), project_path);
- //copy required node_modules
+ //copy required node_modules
shell.cp('-r', path.join(ROOT, 'node_modules'), path.join(project_path,'cordova'));
//copy check_reqs file
- shell.cp( path.join(ROOT, 'bin/lib/check_reqs.js'), path.join(project_path,'cordova/lib'));
+ shell.cp(path.join(ROOT, 'bin/lib/check_reqs.js'), path.join(project_path,'cordova/lib'));
//copy cordova js file
- shell.cp('-r', path.join(ROOT, 'cordova-lib', 'cordova.js'),
+ shell.cp(path.join(ROOT, 'cordova-lib', 'cordova.js'),
path.join(project_path,'www'));
- //copy template directory ( recursive )
- shell.cp('-r', path.join(ROOT, 'bin/template/www'), project_path);
//copy cordova-js-src directory
shell.cp('-rf', path.join(ROOT, 'cordova-js-src'),
path.join(project_path, 'platform_www'));
- //copy cordova directory
- shell.cp('-r', path.join(ROOT, 'bin/template/cordova'), project_path);
+ //copy cordova js file to platform_www
+ shell.cp(path.join(ROOT, 'cordova-lib', 'cordova.js'),
+ path.join(project_path,'platform_www'));
+
return Promise.resolve();
};
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/62e0b067/bin/template/cordova/Api.js
----------------------------------------------------------------------
diff --git a/bin/template/cordova/Api.js b/bin/template/cordova/Api.js
index eb2d593..dced063 100644
--- a/bin/template/cordova/Api.js
+++ b/bin/template/cordova/Api.js
@@ -9,19 +9,16 @@ var shell = require('shelljs');
var path = require('path');
var fs = require('fs');
-var CordovaLogger = require('cordova-common').CordovaLogger;
-var ConfigParser = require('cordova-common').ConfigParser;
-var ActionStack = require('cordova-common').ActionStack;
-var PluginInfo = require('cordova-common').PluginInfo;
-var selfEvents = require('cordova-common').events;
-var xmlHelpers = require('cordova-common').xmlHelpers;
-
-
-
-var PlatformJson = require('cordova-common').PlatformJson;
-
-var PlatformMunger = require('cordova-common').ConfigChanges.PlatformMunger;
-var PluginInfoProvider = require('cordova-common').PluginInfoProvider;
+var cdvcmn = require('cordova-common');
+var CordovaLogger = cdvcmn.CordovaLogger;
+var ConfigParser = cdvcmn.ConfigParser;
+var ActionStack = cdvcmn.ActionStack;
+var PluginInfo = cdvcmn.PluginInfo;
+var selfEvents = cdvcmn.events;
+var xmlHelpers = cdvcmn.xmlHelpers;
+var PlatformJson = cdvcmn.PlatformJson;
+var PlatformMunger = cdvcmn.ConfigChanges.PlatformMunger;
+var PluginInfoProvider = cdvcmn.PluginInfoProvider;
var BrowserParser = require('./browser_parser');
var PLATFORM_NAME = 'browser';
@@ -169,8 +166,6 @@ Api.prototype.prepare = function (cordovaProject,options) {
Api.prototype.addPlugin = function (pluginInfo, installOptions) {
// console.log(new Error().stack);
-
-
if (!pluginInfo) {
return Promise.reject('The parameter is incorrect. The first parameter ' +
'should be valid PluginInfo instance');
@@ -293,11 +288,6 @@ Api.prototype._getInstaller = function(type) {
else {
installer.install(item, plugin_dir, self.root, plugin_id, options, project);
}
-
-// var installerArgs = type === 'asset' ? [wwwDest] :
-// type === 'js-module' ? [plugin_id, wwwDest]:
-// [self.root, plugin_id, options, project];
-// installer.install.apply(null, [item, plugin_dir].concat(installerArgs));
}
};
};
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/62e0b067/bin/template/cordova/browser_handler.js
----------------------------------------------------------------------
diff --git a/bin/template/cordova/browser_handler.js b/bin/template/cordova/browser_handler.js
index 101fc13..2eecaaf 100644
--- a/bin/template/cordova/browser_handler.js
+++ b/bin/template/cordova/browser_handler.js
@@ -21,8 +21,6 @@
var path = require('path');
var fs = require('fs');
var shell = require('shelljs');
-
-
var events = require('cordova-common').events;
module.exports = {
@@ -30,9 +28,21 @@ module.exports = {
return path.join(project_dir, 'www');
},
package_name:function(project_dir) {
+ // this method should the id from root config.xml => <widget id=xxx
//return common.package_name(project_dir, this.www_dir(project_dir));
- console.log('package_name called with ' + project_dir);
- return 'bob';
+ // console.log('package_name called with ' + project_dir);
+ var pkgName = "io.cordova.hellocordova";
+ var widget_id_regex = /(?:<widget\s+id=['"])(\S+)(?:['"])/;
+
+ var configPath = path.join(project_dir,'config.xml');
+ if(fs.existsSync(configPath)) {
+ var configStr = fs.readFileSync(configPath,'utf8');
+ var res = configStr.match(widget_id_regex);
+ if(res && res.length > 1) {
+ pkgName = res[1];
+ }
+ }
+ return pkgName;
},
'js-module': {
install: function (jsModule, plugin_dir, plugin_id, www_dir) {
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/62e0b067/bin/template/cordova/browser_parser.js
----------------------------------------------------------------------
diff --git a/bin/template/cordova/browser_parser.js b/bin/template/cordova/browser_parser.js
index 7efa837..f6f45a4 100644
--- a/bin/template/cordova/browser_parser.js
+++ b/bin/template/cordova/browser_parser.js
@@ -19,14 +19,10 @@
/* jshint sub:true */
-
-
var fs = require('fs'),
path = require('path'),
shell = require('shelljs'),
- //util = require('../util'),
- CordovaError = require('cordova-common').CordovaError,
- Q = require('q');
+ CordovaError = require('cordova-common').CordovaError;
function dirExists(dir) {
return fs.existsSync(dir) && fs.statSync(dir).isDirectory();
@@ -39,7 +35,6 @@ function browser_parser(project) {
this.path = project;
}
-
module.exports = browser_parser;
// Returns a promise.
@@ -58,41 +53,35 @@ browser_parser.prototype.cordovajs_path = function(libDir) {
};
browser_parser.prototype.cordovajs_src_path = function(libDir) {
- console.log("cordovajs_src_path");
+ //console.log("cordovajs_src_path");
var jsPath = path.join(libDir, 'cordova-js-src');
return path.resolve(jsPath);
};
// Replace the www dir with contents of platform_www and app www.
browser_parser.prototype.update_www = function() {
- // console.log("updating www");
-
- var projectRoot = this.path;//util.isCordova(this.path);
+ var projectRoot = this.path;
var app_www = path.join(this.path,"../../www");
var platform_www = path.join(this.path, 'platform_www');
-
var my_www = this.www_dir();
- console.log("my_www = " + my_www);
- console.log("projectRoot = " + projectRoot);
- console.log("app_www = " + app_www);
// Clear the www dir
- shell.rm('-rf', this.www_dir());
- shell.mkdir(this.www_dir());
+ shell.rm('-rf', my_www);
+ shell.mkdir(my_www);
// Copy over all app www assets
var srcPath = path.join(app_www,'*');
var ls = shell.ls(srcPath);
- shell.cp('-rf', srcPath, this.www_dir());
+ shell.cp('-rf', srcPath, my_www);
// Copy over stock platform www assets (cordova.js)
- shell.cp('-rf', path.join(platform_www, '*'), this.www_dir());
+ shell.cp('-rf', path.join(platform_www, '*'), my_www);
};
browser_parser.prototype.update_overrides = function() {
- console.log("update_overrides");
+ // console.log("update_overrides");
return;
-
+ // TODO: ?
// var projectRoot = util.isCordova(this.path);
// var mergesPath = path.join(util.appDir(projectRoot), 'merges', 'browser');
// if(fs.existsSync(mergesPath)) {
@@ -102,19 +91,18 @@ browser_parser.prototype.update_overrides = function() {
};
browser_parser.prototype.config_xml = function(){
- console.log("config_xml ");
return path.join(this.path, 'config.xml');
};
// Returns a promise.
browser_parser.prototype.update_project = function(cfg) {
- console.log("update_project ",cfg);
- return this.update_from_config()
- .then(function(){
- this.update_overrides();
- // util.deleteSvnFolders(this.www_dir());
-
- // Copy munged config.xml to platform www dir
- shell.cp('-rf', path.join(this.www_dir(), '..', 'config.xml'), this.www_dir());
- }.bind(this));
+ var defer = this.update_from_config();
+ var self = this;
+ var www_dir = self.www_dir();
+ defer.then(function(){
+ self.update_overrides();
+ // Copy munged config.xml to platform www dir
+ shell.cp('-rf', path.join(www_dir, '..', 'config.xml'), www_dir);
+ });
+ return defer;
};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[14/25] cordova-browser git commit: update shelljs version,
prepare is working
Posted by pu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/README.md
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/README.md b/node_modules/shelljs/README.md
index d6dcb63..91f110f 100644
--- a/node_modules/shelljs/README.md
+++ b/node_modules/shelljs/README.md
@@ -1,168 +1,141 @@
# ShellJS - Unix shell commands for Node.js
-[](https://gitter.im/shelljs/shelljs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
-[](http://travis-ci.org/shelljs/shelljs)
-[](https://ci.appveyor.com/project/shelljs/shelljs)
+[](https://gitter.im/shelljs/shelljs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+[](https://travis-ci.org/shelljs/shelljs)
+[](https://ci.appveyor.com/project/shelljs/shelljs/branch/master)
+[](https://codecov.io/gh/shelljs/shelljs)
+[](https://www.npmjs.com/package/shelljs)
+[](https://www.npmjs.com/package/shelljs)
-ShellJS is a portable **(Windows/Linux/OS X)** implementation of Unix shell commands on top of the Node.js API. You can use it to eliminate your shell script's dependency on Unix while still keeping its familiar and powerful commands. You can also install it globally so you can run it from outside Node projects - say goodbye to those gnarly Bash scripts!
+ShellJS is a portable **(Windows/Linux/OS X)** implementation of Unix shell
+commands on top of the Node.js API. You can use it to eliminate your shell
+script's dependency on Unix while still keeping its familiar and powerful
+commands. You can also install it globally so you can run it from outside Node
+projects - say goodbye to those gnarly Bash scripts!
-The project is [unit-tested](http://travis-ci.org/shelljs/shelljs) and battled-tested in projects like:
+ShellJS is proudly tested on every node release since `v0.11`!
+
+The project is [unit-tested](http://travis-ci.org/shelljs/shelljs) and battle-tested in projects like:
+ [PDF.js](http://github.com/mozilla/pdf.js) - Firefox's next-gen PDF reader
+ [Firebug](http://getfirebug.com/) - Firefox's infamous debugger
-+ [JSHint](http://jshint.com) - Most popular JavaScript linter
++ [JSHint](http://jshint.com) & [ESLint](http://eslint.org/) - popular JavaScript linters
+ [Zepto](http://zeptojs.com) - jQuery-compatible JavaScript library for modern browsers
+ [Yeoman](http://yeoman.io/) - Web application stack and development tool
+ [Deployd.com](http://deployd.com) - Open source PaaS for quick API backend generation
++ And [many more](https://npmjs.org/browse/depended/shelljs).
-and [many more](https://npmjs.org/browse/depended/shelljs).
+If you have feedback, suggestions, or need help, feel free to post in our [issue
+tracker](https://github.com/shelljs/shelljs/issues).
-If you have feedback, suggestions, or need help, feel free to post in our [issue tracker](https://github.com/shelljs/shelljs/issues).
+Think ShellJS is cool? Check out some related projects in our [Wiki
+page](https://github.com/shelljs/shelljs/wiki)!
-## Installing
+Upgrading from an older version? Check out our [breaking
+changes](https://github.com/shelljs/shelljs/wiki/Breaking-Changes) page to see
+what changes to watch out for while upgrading.
-Via npm:
+## Command line use
-```bash
-$ npm install [-g] shelljs
+If you just want cross platform UNIX commands, checkout our new project
+[shelljs/shx](https://github.com/shelljs/shx), a utility to expose `shelljs` to
+the command line.
+
+For example:
+
+```
+$ shx mkdir -p foo
+$ shx touch foo/bar.txt
+$ shx rm -rf foo
```
-If the global option `-g` is specified, the binary `shjs` will be installed. This makes it possible to
-run ShellJS scripts much like any shell script from the command line, i.e. without requiring a `node_modules` folder:
+## A quick note about the docs
+
+For documentation on all the latest features, check out our
+[README](https://github.com/shelljs/shelljs). To read docs that are consistent
+with the latest release, check out [the npm
+page](https://www.npmjs.com/package/shelljs) or
+[shelljs.org](http://documentup.com/shelljs/shelljs).
+
+## Installing
+
+Via npm:
```bash
-$ shjs my_script
+$ npm install [-g] shelljs
```
## Examples
-### JavaScript
-
```javascript
-require('shelljs/global');
+var shell = require('shelljs');
-if (!which('git')) {
- echo('Sorry, this script requires git');
- exit(1);
+if (!shell.which('git')) {
+ shell.echo('Sorry, this script requires git');
+ shell.exit(1);
}
// Copy files to release dir
-mkdir('-p', 'out/Release');
-cp('-R', 'stuff/*', 'out/Release');
+shell.rm('-rf', 'out/Release');
+shell.cp('-R', 'stuff/', 'out/Release');
// Replace macros in each .js file
-cd('lib');
-ls('*.js').forEach(function(file) {
- sed('-i', 'BUILD_VERSION', 'v0.1.2', file);
- sed('-i', /.*REMOVE_THIS_LINE.*\n/, '', file);
- sed('-i', /.*REPLACE_LINE_WITH_MACRO.*\n/, cat('macro.js'), file);
+shell.cd('lib');
+shell.ls('*.js').forEach(function (file) {
+ shell.sed('-i', 'BUILD_VERSION', 'v0.1.2', file);
+ shell.sed('-i', /^.*REMOVE_THIS_LINE.*$/, '', file);
+ shell.sed('-i', /.*REPLACE_LINE_WITH_MACRO.*\n/, shell.cat('macro.js'), file);
});
-cd('..');
+shell.cd('..');
// Run external tool synchronously
-if (exec('git commit -am "Auto-commit"').code !== 0) {
- echo('Error: Git commit failed');
- exit(1);
+if (shell.exec('git commit -am "Auto-commit"').code !== 0) {
+ shell.echo('Error: Git commit failed');
+ shell.exit(1);
}
```
-### CoffeeScript
-
-CoffeeScript is also supported automatically:
-
-```coffeescript
-require 'shelljs/global'
-
-if not which 'git'
- echo 'Sorry, this script requires git'
- exit 1
-
-# Copy files to release dir
-mkdir '-p', 'out/Release'
-cp '-R', 'stuff/*', 'out/Release'
-
-# Replace macros in each .js file
-cd 'lib'
-for file in ls '*.js'
- sed '-i', 'BUILD_VERSION', 'v0.1.2', file
- sed '-i', /.*REMOVE_THIS_LINE.*\n/, '', file
- sed '-i', /.*REPLACE_LINE_WITH_MACRO.*\n/, cat('macro.js'), file
-cd '..'
-
-# Run external tool synchronously
-if (exec 'git commit -am "Auto-commit"').code != 0
- echo 'Error: Git commit failed'
- exit 1
-```
-
## Global vs. Local
-The example above uses the convenience script `shelljs/global` to reduce verbosity. If polluting your global namespace is not desirable, simply require `shelljs`.
+We no longer recommend using a global-import for ShellJS (i.e.
+`require('shelljs/global')`). While still supported for convenience, this
+pollutes the global namespace, and should therefore only be used with caution.
-Example:
+Instead, we recommend a local import (standard for npm packages):
```javascript
var shell = require('shelljs');
shell.echo('hello world');
```
-## Make tool
+<!-- DO NOT MODIFY BEYOND THIS POINT - IT'S AUTOMATICALLY GENERATED -->
-A convenience script `shelljs/make` is also provided to mimic the behavior of a Unix Makefile.
-In this case all shell objects are global, and command line arguments will cause the script to
-execute only the corresponding function in the global `target` object. To avoid redundant calls,
-target functions are executed only once per script.
-Example:
+## Command reference
-```javascript
-require('shelljs/make');
-target.all = function() {
- target.bundle();
- target.docs();
-};
+All commands run synchronously, unless otherwise stated.
+All commands accept standard bash globbing characters (`*`, `?`, etc.),
+compatible with the [node glob module](https://github.com/isaacs/node-glob).
-target.bundle = function() {
- cd(__dirname);
- mkdir('-p', 'build');
- cd('src');
- cat('*.js').to('../build/output.js');
-};
+For less-commonly used commands and features, please check out our [wiki
+page](https://github.com/shelljs/shelljs/wiki).
-target.docs = function() {
- cd(__dirname);
- mkdir('-p', 'docs');
- var files = ls('src/*.js');
- for(var i = 0; i < files.length; i++) {
- var text = grep('//@', files[i]); // extract special comments
- text = text.replace(/\/\/@/g, ''); // remove comment tags
- text.toEnd('docs/my_docs.md');
- }
-};
-```
-To run the target `all`, call the above script without arguments: `$ node make`. To run the target `docs`: `$ node make docs`.
+### cat(file [, file ...])
+### cat(file_array)
-You can also pass arguments to your targets by using the `--` separator. For example, to pass `arg1` and `arg2` to a target `bundle`, do `$ node make bundle -- arg1 arg2`:
+Examples:
```javascript
-require('shelljs/make');
-
-target.bundle = function(argsArray) {
- // argsArray = ['arg1', 'arg2']
- /* ... */
-}
+var str = cat('file*.txt');
+var str = cat('file1', 'file2');
+var str = cat(['file1', 'file2']); // same as above
```
-
-<!-- DO NOT MODIFY BEYOND THIS POINT - IT'S AUTOMATICALLY GENERATED -->
-
-
-## Command reference
-
-
-All commands run synchronously, unless otherwise stated.
+Returns a string containing the given file, or a concatenated string
+containing the files if more than one file is given (a new line character is
+introduced between each file).
### cd([dir])
@@ -170,48 +143,32 @@ Changes to directory `dir` for the duration of the script. Changes to home
directory if no argument is supplied.
-### pwd()
-Returns the current directory.
+### chmod([options,] octal_mode || octal_string, file)
+### chmod([options,] symbolic_mode, file)
-
-### ls([options,] [path, ...])
-### ls([options,] path_array)
Available options:
-+ `-R`: recursive
-+ `-A`: all files (include files beginning with `.`, except for `.` and `..`)
-+ `-d`: list directories themselves, not their contents
-+ `-l`: list objects representing each file, each with fields containing `ls
- -l` output fields. See
- [fs.Stats](https://nodejs.org/api/fs.html#fs_class_fs_stats)
- for more info
-
-Examples:
-
-```javascript
-ls('projs/*.js');
-ls('-R', '/users/me', '/tmp');
-ls('-R', ['/users/me', '/tmp']); // same as above
-ls('-l', 'file.txt'); // { name: 'file.txt', mode: 33188, nlink: 1, ...}
-```
-
-Returns array of files in the given path, or in current directory if no path provided.
-
++ `-v`: output a diagnostic for every file processed
++ `-c`: like verbose but report only when a change is made
++ `-R`: change files and directories recursively
-### find(path [, path ...])
-### find(path_array)
Examples:
```javascript
-find('src', 'lib');
-find(['src', 'lib']); // same as above
-find('.').filter(function(file) { return file.match(/\.js$/); });
+chmod(755, '/Users/brandon');
+chmod('755', '/Users/brandon'); // same as above
+chmod('u+x', '/Users/brandon');
+chmod('-R', 'a-w', '/Users/brandon');
```
-Returns array of all files (however deep) in the given paths.
+Alters the permissions of a file or directory by either specifying the
+absolute permissions in octal form or expressing the changes in symbols.
+This command tries to mimic the POSIX behavior as much as possible.
+Notable exceptions:
-The main difference from `ls('-R', path)` is that the resulting file names
-include the base directories, e.g. `lib/resources/file1` instead of just `file1`.
++ In symbolic modes, 'a-r' and '-r' are identical. No consideration is
+ given to the umask.
++ There is no "quiet" option since default behavior is to run silent.
### cp([options,] source [, source ...], dest)
@@ -220,340 +177,427 @@ Available options:
+ `-f`: force (default behavior)
+ `-n`: no-clobber
-+ `-r, -R`: recursive
++ `-u`: only copy if source is newer than dest
++ `-r`, `-R`: recursive
++ `-L`: follow symlinks
++ `-P`: don't follow symlinks
Examples:
```javascript
cp('file1', 'dir1');
+cp('-R', 'path/to/dir/', '~/newCopy/');
cp('-Rf', '/tmp/*', '/usr/local/*', '/home/tmp');
cp('-Rf', ['/tmp/*', '/usr/local/*'], '/home/tmp'); // same as above
```
-Copies files. The wildcard `*` is accepted.
+Copies files.
-### rm([options,] file [, file ...])
-### rm([options,] file_array)
+### pushd([options,] [dir | '-N' | '+N'])
+
Available options:
-+ `-f`: force
-+ `-r, -R`: recursive
++ `-n`: Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated.
+
+Arguments:
+
++ `dir`: Makes the current working directory be the top of the stack, and then executes the equivalent of `cd dir`.
++ `+N`: Brings the Nth directory (counting from the left of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.
++ `-N`: Brings the Nth directory (counting from the right of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.
Examples:
```javascript
-rm('-rf', '/tmp/*');
-rm('some_file.txt', 'another_file.txt');
-rm(['some_file.txt', 'another_file.txt']); // same as above
+// process.cwd() === '/usr'
+pushd('/etc'); // Returns /etc /usr
+pushd('+1'); // Returns /usr /etc
```
-Removes files. The wildcard `*` is accepted.
+Save the current directory on the top of the directory stack and then cd to `dir`. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack.
+### popd([options,] ['-N' | '+N'])
-### mv([options ,] source [, source ...], dest')
-### mv([options ,] source_array, dest')
Available options:
-+ `-f`: force (default behavior)
-+ `-n`: no-clobber
++ `-n`: Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated.
+
+Arguments:
+
++ `+N`: Removes the Nth directory (counting from the left of the list printed by dirs), starting with zero.
++ `-N`: Removes the Nth directory (counting from the right of the list printed by dirs), starting with zero.
Examples:
```javascript
-mv('-n', 'file', 'dir/');
-mv('file1', 'file2', 'dir/');
-mv(['file1', 'file2'], 'dir/'); // same as above
+echo(process.cwd()); // '/usr'
+pushd('/etc'); // '/etc /usr'
+echo(process.cwd()); // '/etc'
+popd(); // '/usr'
+echo(process.cwd()); // '/usr'
```
-Moves files. The wildcard `*` is accepted.
+When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack.
+### dirs([options | '+N' | '-N'])
-### mkdir([options,] dir [, dir ...])
-### mkdir([options,] dir_array)
Available options:
-+ `-p`: full path (will create intermediate dirs if necessary)
++ `-c`: Clears the directory stack by deleting all of the elements.
+
+Arguments:
+
++ `+N`: Displays the Nth directory (counting from the left of the list printed by dirs when invoked without options), starting with zero.
++ `-N`: Displays the Nth directory (counting from the right of the list printed by dirs when invoked without options), starting with zero.
+
+Display the list of currently remembered directories. Returns an array of paths in the stack, or a single path if +N or -N was specified.
+
+See also: pushd, popd
+
+
+### echo([options,] string [, string ...])
+Available options:
+
++ `-e`: interpret backslash escapes (default)
Examples:
```javascript
-mkdir('-p', '/tmp/a/b/c/d', '/tmp/e/f/g');
-mkdir('-p', ['/tmp/a/b/c/d', '/tmp/e/f/g']); // same as above
+echo('hello world');
+var str = echo('hello world');
```
-Creates directories.
+Prints string to stdout, and returns string with additional utility methods
+like `.to()`.
-### test(expression)
-Available expression primaries:
+### exec(command [, options] [, callback])
+Available options (all `false` by default):
-+ `'-b', 'path'`: true if path is a block device
-+ `'-c', 'path'`: true if path is a character device
-+ `'-d', 'path'`: true if path is a directory
-+ `'-e', 'path'`: true if path exists
-+ `'-f', 'path'`: true if path is a regular file
-+ `'-L', 'path'`: true if path is a symbolic link
-+ `'-p', 'path'`: true if path is a pipe (FIFO)
-+ `'-S', 'path'`: true if path is a socket
++ `async`: Asynchronous execution. If a callback is provided, it will be set to
+ `true`, regardless of the passed value.
++ `silent`: Do not echo program output to console.
++ and any option available to Node.js's
+ [child_process.exec()](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback)
Examples:
```javascript
-if (test('-d', path)) { /* do something with dir */ };
-if (!test('-f', path)) continue; // skip if it's a regular file
+var version = exec('node --version', {silent:true}).stdout;
+
+var child = exec('some_long_running_process', {async:true});
+child.stdout.on('data', function(data) {
+ /* ... do something with data ... */
+});
+
+exec('some_long_running_process', function(code, stdout, stderr) {
+ console.log('Exit code:', code);
+ console.log('Program output:', stdout);
+ console.log('Program stderr:', stderr);
+});
```
-Evaluates expression using the available primaries and returns corresponding value.
+Executes the given `command` _synchronously_, unless otherwise specified. When in synchronous
+mode, this returns a ShellString (compatible with ShellJS v0.6.x, which returns an object
+of the form `{ code:..., stdout:... , stderr:... }`). Otherwise, this returns the child process
+object, and the `callback` gets the arguments `(code, stdout, stderr)`.
+Not seeing the behavior you want? `exec()` runs everything through `sh`
+by default (or `cmd.exe` on Windows), which differs from `bash`. If you
+need bash-specific behavior, try out the `{shell: 'path/to/bash'}` option.
+
+**Note:** For long-lived processes, it's best to run `exec()` asynchronously as
+the current synchronous implementation uses a lot of CPU. This should be getting
+fixed soon.
-### cat(file [, file ...])
-### cat(file_array)
+### find(path [, path ...])
+### find(path_array)
Examples:
```javascript
-var str = cat('file*.txt');
-var str = cat('file1', 'file2');
-var str = cat(['file1', 'file2']); // same as above
+find('src', 'lib');
+find(['src', 'lib']); // same as above
+find('.').filter(function(file) { return file.match(/\.js$/); });
```
-Returns a string containing the given file, or a concatenated string
-containing the files if more than one file is given (a new line character is
-introduced between each file). Wildcard `*` accepted.
+Returns array of all files (however deep) in the given paths.
+The main difference from `ls('-R', path)` is that the resulting file names
+include the base directories, e.g. `lib/resources/file1` instead of just `file1`.
-### 'string'.to(file)
+
+### grep([options,] regex_filter, file [, file ...])
+### grep([options,] regex_filter, file_array)
+Available options:
+
++ `-v`: Inverse the sense of the regex and print the lines not matching the criteria.
++ `-l`: Print only filenames of matching files
Examples:
```javascript
-cat('input.txt').to('output.txt');
+grep('-v', 'GLOBAL_VARIABLE', '*.js');
+grep('GLOBAL_VARIABLE', '*.js');
```
-Analogous to the redirection operator `>` in Unix, but works with JavaScript strings (such as
-those returned by `cat`, `grep`, etc). _Like Unix redirections, `to()` will overwrite any existing file!_
+Reads input string from given files and returns a string containing all lines of the
+file that match the given `regex_filter`.
-### 'string'.toEnd(file)
+### head([{'-n': \<num\>},] file [, file ...])
+### head([{'-n': \<num\>},] file_array)
+Available options:
+
++ `-n <num>`: Show the first `<num>` lines of the files
Examples:
```javascript
-cat('input.txt').toEnd('output.txt');
+var str = head({'-n': 1}, 'file*.txt');
+var str = head('file1', 'file2');
+var str = head(['file1', 'file2']); // same as above
```
-Analogous to the redirect-and-append operator `>>` in Unix, but works with JavaScript strings (such as
-those returned by `cat`, `grep`, etc).
+Read the start of a file.
-### sed([options,] search_regex, replacement, file [, file ...])
-### sed([options,] search_regex, replacement, file_array)
+### ln([options,] source, dest)
Available options:
-+ `-i`: Replace contents of 'file' in-place. _Note that no backups will be created!_
++ `-s`: symlink
++ `-f`: force
Examples:
```javascript
-sed('-i', 'PROGRAM_VERSION', 'v0.1.3', 'source.js');
-sed(/.*DELETE_THIS_LINE.*\n/, '', 'source.js');
+ln('file', 'newlink');
+ln('-sf', 'file', 'existing');
```
-Reads an input string from `files` and performs a JavaScript `replace()` on the input
-using the given search regex and replacement string or function. Returns the new string after replacement.
+Links source to dest. Use -f to force the link, should dest already exist.
-### grep([options,] regex_filter, file [, file ...])
-### grep([options,] regex_filter, file_array)
+### ls([options,] [path, ...])
+### ls([options,] path_array)
Available options:
-+ `-v`: Inverse the sense of the regex and print the lines not matching the criteria.
++ `-R`: recursive
++ `-A`: all files (include files beginning with `.`, except for `.` and `..`)
++ `-L`: follow symlinks
++ `-d`: list directories themselves, not their contents
++ `-l`: list objects representing each file, each with fields containing `ls
+ -l` output fields. See
+ [fs.Stats](https://nodejs.org/api/fs.html#fs_class_fs_stats)
+ for more info
Examples:
```javascript
-grep('-v', 'GLOBAL_VARIABLE', '*.js');
-grep('GLOBAL_VARIABLE', '*.js');
+ls('projs/*.js');
+ls('-R', '/users/me', '/tmp');
+ls('-R', ['/users/me', '/tmp']); // same as above
+ls('-l', 'file.txt'); // { name: 'file.txt', mode: 33188, nlink: 1, ...}
```
-Reads input string from given files and returns a string containing all lines of the
-file that match the given `regex_filter`. Wildcard `*` accepted.
+Returns array of files in the given path, or in current directory if no path provided.
-### which(command)
+### mkdir([options,] dir [, dir ...])
+### mkdir([options,] dir_array)
+Available options:
+
++ `-p`: full path (will create intermediate dirs if necessary)
Examples:
```javascript
-var nodeExec = which('node');
+mkdir('-p', '/tmp/a/b/c/d', '/tmp/e/f/g');
+mkdir('-p', ['/tmp/a/b/c/d', '/tmp/e/f/g']); // same as above
```
-Searches for `command` in the system's PATH. On Windows, this uses the
-`PATHEXT` variable to append the extension if it's not already executable.
-Returns string containing the absolute path to the command.
+Creates directories.
-### echo(string [, string ...])
+### mv([options ,] source [, source ...], dest')
+### mv([options ,] source_array, dest')
+Available options:
+
++ `-f`: force (default behavior)
++ `-n`: no-clobber
Examples:
```javascript
-echo('hello world');
-var str = echo('hello world');
+mv('-n', 'file', 'dir/');
+mv('file1', 'file2', 'dir/');
+mv(['file1', 'file2'], 'dir/'); // same as above
```
-Prints string to stdout, and returns string with additional utility methods
-like `.to()`.
+Moves files.
-### pushd([options,] [dir | '-N' | '+N'])
+### pwd()
+Returns the current directory.
+
+### rm([options,] file [, file ...])
+### rm([options,] file_array)
Available options:
-+ `-n`: Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated.
++ `-f`: force
++ `-r, -R`: recursive
-Arguments:
+Examples:
+
+```javascript
+rm('-rf', '/tmp/*');
+rm('some_file.txt', 'another_file.txt');
+rm(['some_file.txt', 'another_file.txt']); // same as above
+```
+
+Removes files.
-+ `dir`: Makes the current working directory be the top of the stack, and then executes the equivalent of `cd dir`.
-+ `+N`: Brings the Nth directory (counting from the left of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.
-+ `-N`: Brings the Nth directory (counting from the right of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.
+
+### sed([options,] search_regex, replacement, file [, file ...])
+### sed([options,] search_regex, replacement, file_array)
+Available options:
+
++ `-i`: Replace contents of 'file' in-place. _Note that no backups will be created!_
Examples:
```javascript
-// process.cwd() === '/usr'
-pushd('/etc'); // Returns /etc /usr
-pushd('+1'); // Returns /usr /etc
+sed('-i', 'PROGRAM_VERSION', 'v0.1.3', 'source.js');
+sed(/.*DELETE_THIS_LINE.*\n/, '', 'source.js');
```
-Save the current directory on the top of the directory stack and then cd to `dir`. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack.
+Reads an input string from `files` and performs a JavaScript `replace()` on the input
+using the given search regex and replacement string or function. Returns the new string after replacement.
-### popd([options,] ['-N' | '+N'])
+Note:
-Available options:
+Like unix `sed`, ShellJS `sed` supports capture groups. Capture groups are specified
+using the `$n` syntax:
-+ `-n`: Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated.
+```javascript
+sed(/(\w+)\s(\w+)/, '$2, $1', 'file.txt');
+```
-Arguments:
-+ `+N`: Removes the Nth directory (counting from the left of the list printed by dirs), starting with zero.
-+ `-N`: Removes the Nth directory (counting from the right of the list printed by dirs), starting with zero.
+### set(options)
+Available options:
+
++ `+/-e`: exit upon error (`config.fatal`)
++ `+/-v`: verbose: show all commands (`config.verbose`)
++ `+/-f`: disable filename expansion (globbing)
Examples:
```javascript
-echo(process.cwd()); // '/usr'
-pushd('/etc'); // '/etc /usr'
-echo(process.cwd()); // '/etc'
-popd(); // '/usr'
-echo(process.cwd()); // '/usr'
+set('-e'); // exit upon first error
+set('+e'); // this undoes a "set('-e')"
```
-When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack.
+Sets global configuration variables
-### dirs([options | '+N' | '-N'])
+### sort([options,] file [, file ...])
+### sort([options,] file_array)
Available options:
-+ `-c`: Clears the directory stack by deleting all of the elements.
++ `-r`: Reverse the result of comparisons
++ `-n`: Compare according to numerical value
-Arguments:
-
-+ `+N`: Displays the Nth directory (counting from the left of the list printed by dirs when invoked without options), starting with zero.
-+ `-N`: Displays the Nth directory (counting from the right of the list printed by dirs when invoked without options), starting with zero.
+Examples:
-Display the list of currently remembered directories. Returns an array of paths in the stack, or a single path if +N or -N was specified.
+```javascript
+sort('foo.txt', 'bar.txt');
+sort('-r', 'foo.txt');
+```
-See also: pushd, popd
+Return the contents of the files, sorted line-by-line. Sorting multiple
+files mixes their content, just like unix sort does.
-### ln([options,] source, dest)
+### tail([{'-n': \<num\>},] file [, file ...])
+### tail([{'-n': \<num\>},] file_array)
Available options:
-+ `-s`: symlink
-+ `-f`: force
++ `-n <num>`: Show the last `<num>` lines of the files
Examples:
```javascript
-ln('file', 'newlink');
-ln('-sf', 'file', 'existing');
+var str = tail({'-n': 1}, 'file*.txt');
+var str = tail('file1', 'file2');
+var str = tail(['file1', 'file2']); // same as above
```
-Links source to dest. Use -f to force the link, should dest already exist.
+Read the end of a file.
-### exit(code)
-Exits the current process with the given exit code.
+### tempdir()
-### env['VAR_NAME']
-Object containing environment variables (both getter and setter). Shortcut to process.env.
+Examples:
-### exec(command [, options] [, callback])
-Available options (all `false` by default):
+```javascript
+var tmp = tempdir(); // "/tmp" for most *nix platforms
+```
-+ `async`: Asynchronous execution. If a callback is provided, it will be set to
- `true`, regardless of the passed value.
-+ `silent`: Do not echo program output to console.
-+ and any option available to NodeJS's
- [child_process.exec()](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback)
+Searches and returns string containing a writeable, platform-dependent temporary directory.
+Follows Python's [tempfile algorithm](http://docs.python.org/library/tempfile.html#tempfile.tempdir).
+
+
+### test(expression)
+Available expression primaries:
+
++ `'-b', 'path'`: true if path is a block device
++ `'-c', 'path'`: true if path is a character device
++ `'-d', 'path'`: true if path is a directory
++ `'-e', 'path'`: true if path exists
++ `'-f', 'path'`: true if path is a regular file
++ `'-L', 'path'`: true if path is a symbolic link
++ `'-p', 'path'`: true if path is a pipe (FIFO)
++ `'-S', 'path'`: true if path is a socket
Examples:
```javascript
-var version = exec('node --version', {silent:true}).stdout;
+if (test('-d', path)) { /* do something with dir */ };
+if (!test('-f', path)) continue; // skip if it's a regular file
+```
-var child = exec('some_long_running_process', {async:true});
-child.stdout.on('data', function(data) {
- /* ... do something with data ... */
-});
+Evaluates expression using the available primaries and returns corresponding value.
-exec('some_long_running_process', function(code, stdout, stderr) {
- console.log('Exit code:', code);
- console.log('Program output:', stdout);
- console.log('Program stderr:', stderr);
-});
-```
-Executes the given `command` _synchronously_, unless otherwise specified. When in synchronous
-mode returns the object `{ code:..., stdout:... , stderr:... }`, containing the program's
-`stdout`, `stderr`, and its exit `code`. Otherwise returns the child process object,
-and the `callback` gets the arguments `(code, stdout, stderr)`.
+### ShellString.prototype.to(file)
-**Note:** For long-lived processes, it's best to run `exec()` asynchronously as
-the current synchronous implementation uses a lot of CPU. This should be getting
-fixed soon.
+Examples:
+```javascript
+cat('input.txt').to('output.txt');
+```
-### chmod(octal_mode || octal_string, file)
-### chmod(symbolic_mode, file)
+Analogous to the redirection operator `>` in Unix, but works with
+ShellStrings (such as those returned by `cat`, `grep`, etc). _Like Unix
+redirections, `to()` will overwrite any existing file!_
-Available options:
-+ `-v`: output a diagnostic for every file processed
-+ `-c`: like verbose but report only when a change is made
-+ `-R`: change files and directories recursively
+### ShellString.prototype.toEnd(file)
Examples:
```javascript
-chmod(755, '/Users/brandon');
-chmod('755', '/Users/brandon'); // same as above
-chmod('u+x', '/Users/brandon');
+cat('input.txt').toEnd('output.txt');
```
-Alters the permissions of a file or directory by either specifying the
-absolute permissions in octal form or expressing the changes in symbols.
-This command tries to mimic the POSIX behavior as much as possible.
-Notable exceptions:
-
-+ In symbolic modes, 'a-r' and '-r' are identical. No consideration is
- given to the umask.
-+ There is no "quiet" option since default behavior is to run silent.
+Analogous to the redirect-and-append operator `>>` in Unix, but works with
+ShellStrings (such as those returned by `cat`, `grep`, etc).
-### touch([options,] file)
+### touch([options,] file [, file ...])
+### touch([options,] file_array)
Available options:
+ `-a`: Change only the access time
@@ -575,46 +619,84 @@ A FILE argument that does not exist is created empty, unless -c is supplied.
This is a partial implementation of *[touch(1)](http://linux.die.net/man/1/touch)*.
-### set(options)
+### uniq([options,] [input, [output]])
Available options:
-+ `+/-e`: exit upon error (`config.fatal`)
-+ `+/-v`: verbose: show all commands (`config.verbose`)
++ `-i`: Ignore case while comparing
++ `-c`: Prefix lines by the number of occurrences
++ `-d`: Only print duplicate lines, one for each group of identical lines
Examples:
```javascript
-set('-e'); // exit upon first error
-set('+e'); // this undoes a "set('-e')"
+uniq('foo.txt');
+uniq('-i', 'foo.txt');
+uniq('-cd', 'foo.txt', 'bar.txt');
```
-Sets global configuration variables
+Filter adjacent matching lines from input
-## Non-Unix commands
+### which(command)
+Examples:
+
+```javascript
+var nodeExec = which('node');
+```
+
+Searches for `command` in the system's PATH. On Windows, this uses the
+`PATHEXT` variable to append the extension if it's not already executable.
+Returns string containing the absolute path to the command.
-### tempdir()
+
+### exit(code)
+Exits the current process with the given exit code.
+
+### error()
+Tests if error occurred in the last command. Returns a truthy value if an
+error returned and a falsy value otherwise.
+
+**Note**: do not rely on the
+return value to be an error message. If you need the last error message, use
+the `.stderr` attribute from the last command's return value instead.
+
+
+### ShellString(str)
Examples:
```javascript
-var tmp = tempdir(); // "/tmp" for most *nix platforms
+var foo = ShellString('hello world');
```
-Searches and returns string containing a writeable, platform-dependent temporary directory.
-Follows Python's [tempfile algorithm](http://docs.python.org/library/tempfile.html#tempfile.tempdir).
+Turns a regular string into a string-like object similar to what each
+command returns. This has special methods, like `.to()` and `.toEnd()`
-### error()
-Tests if error occurred in the last command. Returns `null` if no error occurred,
-otherwise returns string explaining the error
+### env['VAR_NAME']
+Object containing environment variables (both getter and setter). Shortcut
+to process.env.
+
+### Pipes
+Examples:
+
+```javascript
+grep('foo', 'file1.txt', 'file2.txt').sed(/o/g, 'a').to('output.txt');
+echo('files with o\'s in the name:\n' + ls().grep('o'));
+cat('test.js').exec('node'); // pipe to exec() call
+```
+
+Commands can send their output to another command in a pipe-like fashion.
+`sed`, `grep`, `cat`, `exec`, `to`, and `toEnd` can appear on the right-hand
+side of a pipe. Pipes can be chained.
## Configuration
### config.silent
+
Example:
```javascript
@@ -629,19 +711,22 @@ Suppresses all command output if `true`, except for `echo()` calls.
Default is `false`.
### config.fatal
+
Example:
```javascript
require('shelljs/global');
config.fatal = true; // or set('-e');
-cp('this_file_does_not_exist', '/dev/null'); // dies here
+cp('this_file_does_not_exist', '/dev/null'); // throws Error here
/* more commands... */
```
-If `true` the script will die on errors. Default is `false`. This is
-analogous to Bash's `set -e`
+If `true` the script will throw a Javascript error when any shell.js
+command encounters an error. Default is `false`. This is analogous to
+Bash's `set -e`
### config.verbose
+
Example:
```javascript
@@ -656,3 +741,45 @@ Will print each command as follows:
cd dir/
ls subdir/
```
+
+### config.globOptions
+
+Example:
+
+```javascript
+config.globOptions = {nodir: true};
+```
+
+Use this value for calls to `glob.sync()` instead of the default options.
+
+### config.reset()
+
+Example:
+
+```javascript
+var shell = require('shelljs');
+// Make changes to shell.config, and do stuff...
+/* ... */
+shell.config.reset(); // reset to original state
+// Do more stuff, but with original settings
+/* ... */
+```
+
+Reset shell.config to the defaults:
+
+```javascript
+{
+ fatal: false,
+ globOptions: {},
+ maxdepth: 255,
+ noglob: false,
+ silent: false,
+ verbose: false,
+}
+```
+
+## Team
+
+| [](https://github.com/nfischer) | [](http://github.com/freitagbr) |
+|:---:|:---:|
+| [Nate Fischer](https://github.com/nfischer) | [Brandon Freitag](http://github.com/freitagbr) |
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/c846b473/node_modules/shelljs/bin/shjs
----------------------------------------------------------------------
diff --git a/node_modules/shelljs/bin/shjs b/node_modules/shelljs/bin/shjs
index aae3bc6..75ca58b 100755
--- a/node_modules/shelljs/bin/shjs
+++ b/node_modules/shelljs/bin/shjs
@@ -32,24 +32,8 @@ for (var i = 0, l = args.length; i < l; i++) {
}
}
-if (scriptName.match(/\.coffee$/)) {
- //
- // CoffeeScript
- //
- if (which('coffee')) {
- exec('coffee "' + scriptName + '" ' + args.join(' '), function(code) {
- process.exit(code);
- });
- } else {
- console.log('ShellJS: CoffeeScript interpreter not found');
- console.log();
- process.exit(1);
- }
-} else {
- //
- // JavaScript
- //
- exec('node "' + scriptName + '" ' + args.join(' '), function(code) {
- process.exit(code);
- });
-}
+var path = require('path');
+var extensions = require('interpret').extensions;
+var rechoir = require('rechoir');
+rechoir.prepare(extensions, scriptName);
+require(require.resolve(path.resolve(process.cwd(), scriptName)));
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org