[Pkg-javascript-commits] [node-cross-spawn-async] 02/07: Imported Upstream version 2.1.1

Ross Gammon ross-guest at moszumanska.debian.org
Wed Dec 23 12:50:58 UTC 2015


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 71156309a6abf164d4b5bd1793d198bd6716a04a
Author: Ross Gammon <rossgammon at mail.dk>
Date:   Wed Dec 23 11:05:15 2015 +0100

    Imported Upstream version 2.1.1
---
 .gitignore            |  1 +
 .travis.yml           |  4 +++
 appveyor.yml          |  6 ++++-
 index.js              |  2 ++
 lib/parse.js          | 13 ++++------
 package.json          | 10 ++++---
 test/test.js          | 72 +++++++++++++++++++++++++++++++++++++++++----------
 test/util/buffered.js | 19 +++++++++-----
 8 files changed, 95 insertions(+), 32 deletions(-)

diff --git a/.gitignore b/.gitignore
index c7fd650..f4fc6e6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@ node_modules/
 npm-debug.*
 test/fixtures/(*
 test/fixtures/shebang_noenv
+test/tmp
diff --git a/.travis.yml b/.travis.yml
index 4feb925..0c27f07 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,3 +2,7 @@ language: node_js
 node_js:
   - '0.10'
   - '0.12'
+  - 'iojs-1'
+  - 'iojs-2'
+  - 'iojs-3'
+  - '4'
diff --git a/appveyor.yml b/appveyor.yml
index 22c6f43..f02a6ba 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -13,10 +13,14 @@ environment:
   matrix:
     - nodejs_version: 0.10
     - nodejs_version: 0.12
+    - nodejs_version: 1
+    - nodejs_version: 2
+    - nodejs_version: 3
+    - nodejs_version: 4
 
 # get the latest stable version of Node 0.STABLE.latest
 install:
-  - ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version)
+  - ps: Install-Product node $env:nodejs_version
   - npm install
 
 build: off
diff --git a/index.js b/index.js
index c8d678d..c1c9a59 100644
--- a/index.js
+++ b/index.js
@@ -21,3 +21,5 @@ function spawn(command, args, options) {
 
 module.exports       = spawn;
 module.exports.spawn = spawn;
+module.exports._parse = parse;
+module.exports._enoent = enoent;
diff --git a/lib/parse.js b/lib/parse.js
index 410c6e3..8ac08b3 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -90,16 +90,13 @@ function parseCall(command, args, options) {
 
     if (isWin) {
         // Detect & add support for shebangs
-        // Note that if we were able to resolve the command, we skip this step entirely
         file = resolveCommand(command);
+        file = file || resolveCommand(command, true);
+        shebang = file && readShebang(file);
 
-        if (!file) {
-            file = resolveCommand(command, true);
-            shebang = file && readShebang(file);
-            if (shebang) {
-                args.unshift(file);
-                command = shebang;
-            }
+        if (shebang) {
+            args.unshift(file);
+            command = shebang;
         }
 
         // Escape command & arguments
diff --git a/package.json b/package.json
index f56cf7e..a140981 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "cross-spawn-async",
-  "version": "2.0.0",
+  "version": "2.1.0",
   "description": "Cross platform child_process#spawn",
   "main": "index.js",
   "scripts": {
@@ -30,12 +30,14 @@
   "author": "IndigoUnited <hello at indigounited.com> (http://indigounited.com)",
   "license": "MIT",
   "dependencies": {
-    "lru-cache": "^2.6.5",
-    "which": "^1.1.1"
+    "lru-cache": "^3.2.0",
+    "which": "^1.2.0"
   },
   "devDependencies": {
     "expect.js": "^0.3.0",
     "glob": "^5.0.12",
-    "mocha": "^2.2.5"
+    "mkdirp": "^0.5.1",
+    "mocha": "^2.2.5",
+    "rimraf": "^1.0.9"
   }
 }
diff --git a/test/test.js b/test/test.js
index 083a95c..cec6f58 100644
--- a/test/test.js
+++ b/test/test.js
@@ -3,6 +3,8 @@
 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('../');
@@ -19,22 +21,34 @@ if (isWin) {
     .join(path.delimiter);
 }
 
-describe('cross-spawn', function () {
-    it('should support shebang in executables (with /usr/bin/env)', function (next) {
-        buffered(__dirname + '/fixtures/shebang', function (err, data, code) {
-            var envPath;
+describe('cross-spawn-async', function () {
+    var originalPath = process.env.PATH;
+
+    before(function () {
+        mkdirp.sync(__dirname + '/tmp');
+    });
+
+    after(function (next) {
+        rimraf(__dirname + '/tmp', function (err) {
+            // Ignore errors, RIMRAF was giving problems on windows
+            next(null);
+        });
+    });
+
+    afterEach(function () {
+        process.env.PATH = originalPath;
+    });
 
+    it('should support shebang in executables with /usr/bin/env', function (next) {
+        buffered(__dirname + '/fixtures/shebang', function (err, data, code) {
             expect(err).to.not.be.ok();
             expect(code).to.be(0);
             expect(data).to.equal('shebang works!');
 
             // Test if the actual shebang file is resolved against the PATH
-            envPath = process.env.PATH;
             process.env.PATH = path.normalize(__dirname + '/fixtures/') + path.delimiter + process.env.PATH;
 
             buffered('shebang', function (err, data, code) {
-                process.env.PATH = envPath;
-
                 expect(err).to.not.be.ok();
                 expect(code).to.be(0);
                 expect(data).to.equal('shebang works!');
@@ -44,7 +58,7 @@ describe('cross-spawn', function () {
         });
     });
 
-    it('should support shebang in executables (without /usr/bin/env)', function (next) {
+    it('should support shebang in executables without /usr/bin/env', function (next) {
         var nodejs = which.sync('node');
         var file = __dirname + '/fixtures/shebang_noenv';
 
@@ -53,19 +67,14 @@ describe('cross-spawn', function () {
         });
 
         buffered(file, function (err, data, code) {
-            var envPath;
-
             expect(err).to.not.be.ok();
             expect(code).to.be(0);
             expect(data).to.equal('shebang works!');
 
             // Test if the actual shebang file is resolved against the PATH
-            envPath = process.env.PATH;
             process.env.PATH = path.normalize(__dirname + '/fixtures/') + path.delimiter + process.env.PATH;
 
             buffered('shebang_noenv', function (err, data, code) {
-                process.env.PATH = envPath;
-
                 expect(err).to.not.be.ok();
                 expect(code).to.be(0);
                 expect(data).to.equal('shebang works!');
@@ -75,6 +84,43 @@ describe('cross-spawn', 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) });
+        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 extensions', function (next) {
+        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) {
+            expect(err).to.not.be.ok();
+            expect(code).to.be(0);
+            expect(data).to.equal('shebang with extension');
+
+            // Test if the actual shebang file is resolved against the PATH
+            process.env.PATH = path.normalize(__dirname + '/fixtures/') + path.delimiter + process.env.PATH;
+
+            buffered('shebang.js', function (err, data, code) {
+                expect(err).to.not.be.ok();
+                expect(code).to.be(0);
+                expect(data).to.equal('shebang with extension');
+
+                next();
+            });
+        });
+    });
+
     it('should expand using PATHEXT properly', function (next) {
         buffered(__dirname + '/fixtures/foo', function (err, data, code) {
             expect(err).to.not.be.ok();
diff --git a/test/util/buffered.js b/test/util/buffered.js
index e9ce32d..b0d8975 100644
--- a/test/util/buffered.js
+++ b/test/util/buffered.js
@@ -4,7 +4,8 @@ var spawn = require('../../');
 
 function buffered(command, args, options, callback) {
     var cp;
-    var data = null;
+    var stdout = null;
+    var stderr = null;
 
     if (typeof options === 'function') {
         callback = options;
@@ -18,15 +19,21 @@ function buffered(command, args, options, callback) {
 
     cp = spawn(command, args, options);
 
-    cp.stdout && cp.stdout.on('data', function(buffer) {
-        data = data || '';
-        data += buffer.toString();
+    cp.stdout && cp.stdout.on('data', function (buffer) {
+        stdout = stdout || '';
+        stdout += buffer.toString();
+    });
+
+    cp.stderr && cp.stderr.on('data', function (buffer) {
+        stderr = stderr || '';
+        stderr += buffer.toString();
     });
 
     cp.on('error', callback);
 
-    cp.on('close', function(code) {
-        callback(null, data, code);
+    cp.on('close', function (code) {
+        code !== 0 && stderr && console.warn(stderr);
+        callback(null, stdout, code);
     });
 }
 

-- 
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