[Pkg-javascript-commits] [node-cross-spawn-async] 01/09: Imported Upstream version 2.2.5

Ross Gammon ross-guest at moszumanska.debian.org
Sat Nov 12 18:43:08 UTC 2016


This is an automated email from the git hooks/post-receive script.

ross-guest pushed a commit to branch master
in repository node-cross-spawn-async.

commit ed4b5d283107359c011905072bbcadf449b738aa
Author: Ross Gammon <rossgammon at mail.dk>
Date:   Sat Nov 12 16:47:54 2016 +0100

    Imported Upstream version 2.2.5
---
 .eslintrc             |  7 +++++
 .jshintrc             | 62 -----------------------------------------
 .travis.yml           |  5 ++--
 README.md             |  8 ++++--
 appveyor.yml          |  5 ++--
 index.js              |  8 ++++--
 lib/enoent.js         |  4 +--
 lib/parse.js          | 29 ++++++++++----------
 lib/resolveCommand.js | 25 +++++++++++------
 lib/util/mixIn.js     | 15 ----------
 package.json          | 11 +++++---
 test/.eslintrc        |  8 ++++++
 test/fixtures/echo.js |  2 ++
 test/fixtures/exit.js |  2 ++
 test/fixtures/shebang |  2 ++
 test/prepare.js       |  6 ++--
 test/test.js          | 76 ++++++++++++++++++++++++++++++++++++---------------
 17 files changed, 133 insertions(+), 142 deletions(-)

diff --git a/.eslintrc b/.eslintrc
new file mode 100644
index 0000000..f34b41d
--- /dev/null
+++ b/.eslintrc
@@ -0,0 +1,7 @@
+{
+    "root": true,
+    "extends": [
+        "@satazor/eslint-config/es5",
+        "@satazor/eslint-config/addons/node"
+    ]
+}
\ No newline at end of file
diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index 5595ed2..0000000
--- a/.jshintrc
+++ /dev/null
@@ -1,62 +0,0 @@
-{
-    "predef": [
-        "console",
-        "describe",
-        "it",
-        "after",
-        "afterEach",
-        "before",
-        "beforeEach"
-    ],
-
-    "indent": 4,
-    "node": true,
-    "devel": true,
-
-    "bitwise": false,
-    "curly": false,
-    "eqeqeq": true,
-    "forin": false,
-    "immed": true,
-    "latedef": false,
-    "newcap": true,
-    "noarg": true,
-    "noempty": false,
-    "nonew": true,
-    "plusplus": false,
-    "regexp": false,
-    "undef": true,
-    "unused": "vars",
-    "quotmark": "single",
-    "strict": false,
-    "trailing": true,
-    "camelcase": true,
-
-    "asi": false,
-    "boss": true,
-    "debug": false,
-    "eqnull": true,
-    "es5": false,
-    "esnext": false,
-    "evil": false,
-    "expr": true,
-    "funcscope": false,
-    "globalstrict": false,
-    "iterator": false,
-    "lastsemic": false,
-    "laxbreak": true,
-    "laxcomma": false,
-    "loopfunc": true,
-    "multistr": false,
-    "onecase": true,
-    "regexdash": false,
-    "scripturl": false,
-    "smarttabs": false,
-    "shadow": false,
-    "sub": false,
-    "supernew": true,
-    "validthis": false,
-
-    "nomen": false,
-    "white": true
-}
diff --git a/.travis.yml b/.travis.yml
index 0c27f07..22e38a0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,7 +2,6 @@ language: node_js
 node_js:
   - '0.10'
   - '0.12'
-  - 'iojs-1'
-  - 'iojs-2'
-  - 'iojs-3'
   - '4'
+  - '5'
+  - '6'
diff --git a/README.md b/README.md
index 1ff1fc3..8b3bd69 100644
--- a/README.md
+++ b/README.md
@@ -6,9 +6,9 @@
 [downloads-image]:http://img.shields.io/npm/dm/cross-spawn-async.svg
 [npm-image]:http://img.shields.io/npm/v/cross-spawn-async.svg
 [travis-url]:https://travis-ci.org/IndigoUnited/node-cross-spawn-async
-[travis-image]:http://img.shields.io/travis/IndigoUnited/node-cross-spawn-async.svg
+[travis-image]:http://img.shields.io/travis/IndigoUnited/node-cross-spawn-async/master.svg
 [appveyor-url]:https://ci.appveyor.com/project/satazor/node-cross-spawn-async
-[appveyor-image]:https://img.shields.io/appveyor/ci/satazor/node-cross-spawn-async.svg
+[appveyor-image]:https://img.shields.io/appveyor/ci/satazor/node-cross-spawn-async/master.svg
 [david-dm-url]:https://david-dm.org/IndigoUnited/node-cross-spawn-async
 [david-dm-image]:https://img.shields.io/david/IndigoUnited/node-cross-spawn-async.svg
 [david-dm-dev-url]:https://david-dm.org/IndigoUnited/node-cross-spawn-async#info=devDependencies
@@ -16,6 +16,8 @@
 
 A cross platform solution to node's spawn.
 
+**This module is deprecated, use [cross-spawn](https://github.com/IndigoUnited/node-cross-spawn) instead which no longer requires a build toolchain.**
+
 
 ## Installation
 
@@ -42,7 +44,7 @@ Exactly the same way as node's [`spawn`](https://nodejs.org/api/child_process.ht
 ```javascript
 var spawn = require('cross-spawn-async');
 
-var process = spawn('npm', ['list', '-g', '-depth', '0'], { stdio: 'inherit' });
+var child = spawn('npm', ['list', '-g', '-depth', '0'], { stdio: 'inherit' });
 ```
 
 
diff --git a/appveyor.yml b/appveyor.yml
index 02aad11..9b92823 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -13,10 +13,9 @@ environment:
   matrix:
     - nodejs_version: 0.10
     - nodejs_version: 0.12
-    - nodejs_version: 1
-    - nodejs_version: 2
-    - nodejs_version: 3
     - nodejs_version: 4
+    - nodejs_version: 5
+    - nodejs_version: 6
 
 # get the latest stable version of Node 0.STABLE.latest
 install:
diff --git a/index.js b/index.js
index c1c9a59..92afff0 100644
--- a/index.js
+++ b/index.js
@@ -1,5 +1,7 @@
-var cp     = require('child_process');
-var parse  = require('./lib/parse');
+'use strict';
+
+var cp = require('child_process');
+var parse = require('./lib/parse');
 var enoent = require('./lib/enoent');
 
 function spawn(command, args, options) {
@@ -19,7 +21,7 @@ function spawn(command, args, options) {
     return spawned;
 }
 
-module.exports       = spawn;
+module.exports = spawn;
 module.exports.spawn = spawn;
 module.exports._parse = parse;
 module.exports._enoent = enoent;
diff --git a/lib/enoent.js b/lib/enoent.js
index e09d7f5..3254833 100644
--- a/lib/enoent.js
+++ b/lib/enoent.js
@@ -47,5 +47,5 @@ function verifyENOENT(status, parsed, syscall) {
 }
 
 module.exports.hookChildProcess = hookChildProcess;
-module.exports.verifyENOENT     = verifyENOENT;
-module.exports.notFoundError    = notFoundError;
+module.exports.verifyENOENT = verifyENOENT;
+module.exports.notFoundError = notFoundError;
diff --git a/lib/parse.js b/lib/parse.js
index 542ef6d..923e05e 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -1,10 +1,11 @@
-var fs             = require('fs');
-var LRU            = require('lru-cache');
+'use strict';
+
+var fs = require('fs');
+var LRU = require('lru-cache');
 var resolveCommand = require('./resolveCommand');
-var mixIn          = require('./util/mixIn');
 
-var isWin        = process.platform === 'win32';
-var shebangCache = LRU({ max: 50, maxAge: 30 * 1000 });  // Cache just for 30sec
+var isWin = process.platform === 'win32';
+var shebangCache = new LRU({ max: 50, maxAge: 30 * 1000 });  // Cache just for 30sec
 
 function readShebang(command) {
     var buffer;
@@ -24,10 +25,10 @@ function readShebang(command) {
         fd = fs.openSync(command, 'r');
         fs.readSync(fd, buffer, 0, 150, 0);
         fs.closeSync(fd);
-    } catch (e) {}
+    } catch (e) { /* empty */ }
 
     // Check if it is a shebang
-    match = buffer.toString().trim().match(/\#\!(.+)/i);
+    match = buffer.toString().trim().match(/#!(.+)/i);
 
     if (match) {
         shebang = match[1].replace(/\/usr\/bin\/env\s+/i, '');   // Remove /usr/bin/env
@@ -46,11 +47,11 @@ function escapeArg(arg, quote) {
     // If we are not going to quote the argument,
     // escape shell metacharacters, including double and single quotes:
     if (!quote) {
-        arg = arg.replace(/([\(\)%!\^<>&|;,"' ])/g, '^$1');
+        arg = arg.replace(/([\(\)%!\^<>&|;,"'\s])/g, '^$1');
     } else {
         // Sequence of backslashes followed by a double quote:
         // double up all the backslashes and escape the double quote
-        arg = arg.replace(/(\\*)"/gi, '$1$1\\"');
+        arg = arg.replace(/(\\*)"/g, '$1$1\\"');
 
         // Sequence of backslashes followed by the end of the string
         // (which will become a double quote later):
@@ -69,11 +70,11 @@ function escapeArg(arg, quote) {
 function escapeCommand(command) {
     // Do not escape if this command is not dangerous..
     // We do this so that commands like "echo" or "ifconfig" work
-    // Quoting them, will make them unnaccessible
+    // Quoting them, will make them unaccessible
     return /^[a-z0-9_-]+$/i.test(command) ? command : escapeArg(command, true);
 }
 
-function parseCall(command, args, options) {
+function parse(command, args, options) {
     var shebang;
     var applyQuotes;
     var file;
@@ -86,7 +87,7 @@ function parseCall(command, args, options) {
     }
 
     args = args ? args.slice(0) : [];  // Clone array to avoid changing the original
-    options = mixIn({}, options);
+    options = options || {};
     original = command;
 
     if (isWin) {
@@ -120,8 +121,8 @@ function parseCall(command, args, options) {
         args: args,
         options: options,
         file: file,
-        original: original
+        original: original,
     };
 }
 
-module.exports = parseCall;
+module.exports = parse;
diff --git a/lib/resolveCommand.js b/lib/resolveCommand.js
index 943d895..391d3d9 100644
--- a/lib/resolveCommand.js
+++ b/lib/resolveCommand.js
@@ -1,29 +1,36 @@
 'use strict';
 
-var path  = require('path');
+var path = require('path');
 var which = require('which');
-var LRU   = require('lru-cache');
+var LRU = require('lru-cache');
 
-var resolveCache = LRU({ max: 50, maxAge: 30 * 1000 });  // Cache just for 30sec
+var commandCache = new LRU({ max: 50, maxAge: 30 * 1000 });  // Cache just for 30sec
+var hasSepInPathRegExp = new RegExp(process.platform === 'win32' ? /[\/\\]/ : /\//);
 
 function resolveCommand(command, noExtension) {
     var resolved;
 
+    // If command looks like a file path, make it absolute to make it canonical
+    // and also to circuvent a bug in which, see: https://github.com/npm/node-which/issues/33
+    if (hasSepInPathRegExp.test(command)) {
+        command = path.resolve(command);
+    }
+
     noExtension = !!noExtension;
-    resolved = resolveCache.get(command + '!' + noExtension);
+    resolved = commandCache.get(command + '!' + noExtension);
 
     // Check if its resolved in the cache
-    if (resolveCache.has(command)) {
-        return resolveCache.get(command);
+    if (commandCache.has(command)) {
+        return commandCache.get(command);
     }
 
     try {
         resolved = !noExtension ?
             which.sync(command) :
-            which.sync(command, { pathExt: path.delimiter + (process.env.PATHEXT || '')  });
-    } catch (e) {}
+            which.sync(command, { pathExt: path.delimiter + (process.env.PATHEXT || '') });
+    } catch (e) { /* empty */ }
 
-    resolveCache.set(command + '!' + noExtension, resolved);
+    commandCache.set(command + '!' + noExtension, resolved);
 
     return resolved;
 }
diff --git a/lib/util/mixIn.js b/lib/util/mixIn.js
deleted file mode 100644
index 9483f8b..0000000
--- a/lib/util/mixIn.js
+++ /dev/null
@@ -1,15 +0,0 @@
-'use strict';
-
-function mixIn(target, source) {
-    var key;
-
-    // No need to check for hasOwnProperty.. this is used
-    // just in plain objects
-    for (key in source) {
-        target[key] = source[key];
-    }
-
-    return target;
-}
-
-module.exports = mixIn;
diff --git a/package.json b/package.json
index 11bbf66..5026fa4 100644
--- a/package.json
+++ b/package.json
@@ -1,10 +1,11 @@
 {
   "name": "cross-spawn-async",
-  "version": "2.1.9",
+  "version": "2.2.5",
   "description": "Cross platform child_process#spawn",
   "main": "index.js",
   "scripts": {
-    "test": "node test/prepare && mocha --bail test/test"
+    "test": "node test/prepare && mocha --bail test/test",
+    "lint": "eslint '{*.js,lib/**/*.js,test/**/*.js}'"
   },
   "bugs": {
     "url": "https://github.com/IndigoUnited/node-cross-spawn-async/issues/"
@@ -31,13 +32,15 @@
   "license": "MIT",
   "dependencies": {
     "lru-cache": "^4.0.0",
-    "which": "^1.2.4"
+    "which": "^1.2.8"
   },
   "devDependencies": {
+    "@satazor/eslint-config": "^3.0.0",
+    "eslint": "^3.0.0",
     "expect.js": "^0.3.0",
     "glob": "^7.0.0",
     "mkdirp": "^0.5.1",
-    "mocha": "^2.2.5",
+    "mocha": "^3.0.2",
     "rimraf": "^2.5.0"
   }
 }
diff --git a/test/.eslintrc b/test/.eslintrc
new file mode 100644
index 0000000..ab3f2d6
--- /dev/null
+++ b/test/.eslintrc
@@ -0,0 +1,8 @@
+{
+    "env": {
+        "mocha": true
+    },
+    "rules": {
+        "no-invalid-this": 0
+    }
+}
\ No newline at end of file
diff --git a/test/fixtures/echo.js b/test/fixtures/echo.js
index 430da7a..133540b 100755
--- a/test/fixtures/echo.js
+++ b/test/fixtures/echo.js
@@ -1,3 +1,5 @@
+'use strict';
+
 var args = process.argv.slice(2);
 
 args.forEach(function (arg, index) {
diff --git a/test/fixtures/exit.js b/test/fixtures/exit.js
index ea1a66f..9b1890e 100644
--- a/test/fixtures/exit.js
+++ b/test/fixtures/exit.js
@@ -1 +1,3 @@
+'use strict';
+
 process.exit(25);
diff --git a/test/fixtures/shebang b/test/fixtures/shebang
index 5650cbd..373d191 100755
--- a/test/fixtures/shebang
+++ b/test/fixtures/shebang
@@ -1,3 +1,5 @@
 #!/usr/bin/env node
 
+'use strict';
+
 process.stdout.write('shebang works!');
diff --git a/test/prepare.js b/test/prepare.js
index addb078..d52071b 100644
--- a/test/prepare.js
+++ b/test/prepare.js
@@ -1,5 +1,7 @@
+'use strict';
+
 var glob = require('glob');
-var fs   = require('fs');
+var fs = require('fs');
 
 var fixturesDir = __dirname + '/fixtures';
 
@@ -8,7 +10,7 @@ glob.sync('prepare_*', { cwd: __dirname + '/fixtures' }).forEach(function (file)
     var finalFile = file.replace(/^prepare_/, '').replace(/\.sh$/, '');
 
     fs.writeFileSync(fixturesDir + '/' + finalFile, contents);
-    fs.chmodSync(fixturesDir + '/' + finalFile, 0777);
+    fs.chmodSync(fixturesDir + '/' + finalFile, parseInt('0777', 8));
 
     process.stdout.write('Copied "' + file + '" to "' + finalFile + '"\n');
 });
diff --git a/test/test.js b/test/test.js
index e98ad8f..209e505 100644
--- a/test/test.js
+++ b/test/test.js
@@ -1,15 +1,15 @@
 'use strict';
 
-var path     = require('path');
-var fs       = require('fs');
-var which    = require('which');
-var rimraf   = require('rimraf');
-var mkdirp   = require('mkdirp');
-var expect   = require('expect.js');
+var path = require('path');
+var fs = require('fs');
+var which = require('which');
+var rimraf = require('rimraf');
+var mkdirp = require('mkdirp');
+var expect = require('expect.js');
 var buffered = require('./util/buffered');
-var spawn    = require('../');
+var spawn = require('../');
 
-var isWin    = process.platform === 'win32';
+var isWin = process.platform === 'win32';
 
 // Fix AppVeyor tests because Git bin folder is in PATH and it has a "echo" program there
 if (isWin) {
@@ -32,7 +32,7 @@ describe('cross-spawn-async', function () {
         // Give it some time, RIMRAF was giving problems on windows
         this.timeout(10000);
 
-        rimraf(__dirname + '/tmp', function (err) {
+        rimraf(__dirname + '/tmp', function () {
             // Ignore errors, RIMRAF was giving problems on windows
             next(null);
         });
@@ -66,7 +66,7 @@ describe('cross-spawn-async', function () {
         var file = __dirname + '/fixtures/shebang_noenv';
 
         fs.writeFileSync(file, '#!' + nodejs + '\n\nprocess.stdout.write(\'shebang works!\');', {
-            mode: parseInt('0777', 8)
+            mode: parseInt('0777', 8),
         });
 
         buffered(file, function (err, data, code) {
@@ -90,7 +90,24 @@ describe('cross-spawn-async', function () {
     it('should support shebang in executables with relative path', function (next) {
         var executable = './' + path.relative(process.cwd(), __dirname + '/fixtures/shebang');
 
-        fs.writeFileSync(__dirname + '/tmp/shebang', '#!/usr/bin/env node\n\nprocess.stdout.write(\'yeah\');', { mode: parseInt('0777', 8) });
+        fs.writeFileSync(__dirname + '/tmp/shebang', '#!/usr/bin/env node\n\nprocess.stdout.write(\'yeah\');',
+            { mode: parseInt('0777', 8) });
+        process.env.PATH = path.normalize(__dirname + '/tmp/') + path.delimiter + process.env.PATH;
+
+        buffered(executable, function (err, data, code) {
+            expect(err).to.not.be.ok();
+            expect(code).to.be(0);
+            expect(data).to.equal('shebang works!');
+
+            next();
+        });
+    });
+
+    it('should support shebang in executables with relative path that starts with `..`', function (next) {
+        var executable = '../' + path.basename(process.cwd()) + '/' + path.relative(process.cwd(), __dirname + '/fixtures/shebang');
+
+        fs.writeFileSync(__dirname + '/tmp/shebang', '#!/usr/bin/env node\n\nprocess.stdout.write(\'yeah\');',
+            { mode: parseInt('0777', 8) });
         process.env.PATH = path.normalize(__dirname + '/tmp/') + path.delimiter + process.env.PATH;
 
         buffered(executable, function (err, data, code) {
@@ -103,7 +120,8 @@ describe('cross-spawn-async', function () {
     });
 
     it('should support shebang in executables with extensions', function (next) {
-        fs.writeFileSync(__dirname + '/tmp/shebang.js', '#!/usr/bin/env node\n\nprocess.stdout.write(\'shebang with extension\');', { mode: parseInt('0777', 8) });
+        fs.writeFileSync(__dirname + '/tmp/shebang.js', '#!/usr/bin/env node\n\nprocess.stdout.write(\'shebang with extension\');',
+            { mode: parseInt('0777', 8) });
         process.env.PATH = path.normalize(__dirname + '/tmp/') + path.delimiter + process.env.PATH;
 
         buffered(__dirname + '/tmp/shebang.js', function (err, data, code) {
@@ -154,12 +172,26 @@ describe('cross-spawn-async', function () {
         });
     });
 
+    it('should handle arguments with quotes', function (next) {
+        buffered('node', [
+            __dirname + '/fixtures/echo',
+            '"foo"',
+            'foo"bar"foo',
+        ], function (err, data, code) {
+            expect(err).to.not.be.ok();
+            expect(code).to.be(0);
+            expect(data).to.equal('"foo"\nfoo"bar"foo');
+
+            next();
+        });
+    });
+
     it('should handle empty arguments', function (next) {
         buffered('node', [
             __dirname + '/fixtures/echo',
             'foo',
             '',
-            'bar'
+            'bar',
         ], function (err, data, code) {
             expect(err).to.not.be.ok();
             expect(code).to.be(0);
@@ -168,7 +200,7 @@ describe('cross-spawn-async', function () {
             buffered('echo', [
                 'foo',
                 '',
-                'bar'
+                'bar',
             ], function (err, data, code) {
                 expect(err).to.not.be.ok();
                 expect(code).to.be(0);
@@ -182,7 +214,7 @@ describe('cross-spawn-async', function () {
     it('should handle non-string arguments', function (next) {
         buffered('node', [
             __dirname + '/fixtures/echo',
-            1234
+            1234,
         ], function (err, data, code) {
             expect(err).to.not.be.ok();
             expect(code).to.be(0);
@@ -196,7 +228,7 @@ describe('cross-spawn-async', function () {
         buffered('node', [
             __dirname + '/fixtures/echo',
             'I am',
-            'André Cruz'
+            'André Cruz',
         ], function (err, data, code) {
             expect(err).to.not.be.ok();
             expect(code).to.be(0);
@@ -211,7 +243,7 @@ describe('cross-spawn-async', function () {
             __dirname + '/fixtures/echo',
             'foo',
             '\\"',
-            'bar'
+            'bar',
         ], function (err, data, code) {
             expect(err).to.not.be.ok();
             expect(code).to.be(0);
@@ -226,7 +258,7 @@ describe('cross-spawn-async', function () {
             __dirname + '/fixtures/echo',
             'foo',
             'bar\\',
-            'baz'
+            'baz',
         ], function (err, data, code) {
             expect(err).to.not.be.ok();
             expect(code).to.be(0);
@@ -251,7 +283,7 @@ describe('cross-spawn-async', function () {
             '|;',
             'foo',
             ', ',
-            'foo'
+            'foo',
         ], function (err, data, code) {
             expect(err).to.not.be.ok();
             expect(code).to.be(0);
@@ -280,7 +312,7 @@ describe('cross-spawn-async', function () {
                 '|;',
                 'foo',
                 ', ',
-                'foo'
+                'foo',
             ], function (err, data, code) {
                 expect(err).to.not.be.ok();
                 expect(code).to.be(0);
@@ -408,7 +440,7 @@ describe('cross-spawn-async', function () {
         this.timeout(5000);
 
         spawned = spawn(__dirname + '/fixtures/shebang_enoent')
-        .on('error', function (err) {
+        .on('error', function () {
             spawned.removeAllListeners();
             clearTimeout(timeout);
             next(new Error('Should not emit error'));
@@ -433,7 +465,7 @@ describe('cross-spawn-async', function () {
         this.timeout(5000);
 
         spawned = spawn(__dirname + '/fixtures/exit1')
-        .on('error', function (err) {
+        .on('error', function () {
             spawned.removeAllListeners();
             clearTimeout(timeout);
             next(new Error('Should not emit error'));

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-cross-spawn-async.git



More information about the Pkg-javascript-commits mailing list