Git Product home page Git Product logo

node-cross-spawn's Introduction

cross-spawn

NPM version Downloads Build Status Build status Coverage Status Dependency status Dev Dependency status

A cross platform solution to node's spawn and spawnSync.

Installation

Node.js version 8 and up: $ npm install cross-spawn

Node.js version 7 and under: $ npm install cross-spawn@6

Why

Node has issues when using spawn on Windows:

  • It ignores PATHEXT
  • It does not support shebangs
  • Has problems running commands with spaces
  • Has problems running commands with posix relative paths (e.g.: ./my-folder/my-executable)
  • Has an issue with command shims (files in node_modules/.bin/), where arguments with quotes and parenthesis would result in invalid syntax error
  • No options.shell support on node <v4.8

All these issues are handled correctly by cross-spawn. There are some known modules, such as win-spawn, that try to solve this but they are either broken or provide faulty escaping of shell arguments.

Usage

Exactly the same way as node's spawn or spawnSync, so it's a drop in replacement.

const spawn = require('cross-spawn');

// Spawn NPM asynchronously
const child = spawn('npm', ['list', '-g', '-depth', '0'], { stdio: 'inherit' });

// Spawn NPM synchronously
const result = spawn.sync('npm', ['list', '-g', '-depth', '0'], { stdio: 'inherit' });

Caveats

Using options.shell as an alternative to cross-spawn

Starting from node v4.8, spawn has a shell option that allows you run commands from within a shell. This new option solves the PATHEXT issue but:

  • It's not supported in node <v4.8
  • You must manually escape the command and arguments which is very error prone, specially when passing user input
  • There are a lot of other unresolved issues from the Why section that you must take into account

If you are using the shell option to spawn a command in a cross platform way, consider using cross-spawn instead. You have been warned.

options.shell support

While cross-spawn adds support for options.shell in node <v4.8, all of its enhancements are disabled.

This mimics the Node.js behavior. More specifically, the command and its arguments will not be automatically escaped nor shebang support will be offered. This is by design because if you are using options.shell you are probably targeting a specific platform anyway and you don't want things to get into your way.

Shebangs support

While cross-spawn handles shebangs on Windows, its support is limited. More specifically, it just supports #!/usr/bin/env <program> where <program> must not contain any arguments.
If you would like to have the shebang support improved, feel free to contribute via a pull-request.

Remember to always test your code on Windows!

Tests

$ npm test
$ npm test -- --watch during development

License

Released under the MIT License.

node-cross-spawn's People

Contributors

andys8 avatar bgotink avatar chalker avatar claudiopro avatar dineshks1 avatar ehmicky avatar forbeslindesay avatar fson avatar greenkeeper[bot] avatar greenkeeperio-bot avatar jamesmessinger avatar johanneswuerbach avatar kevva avatar knpwrs avatar satazor avatar siilwyn avatar timdp avatar typicode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-cross-spawn's Issues

npm install fails on raspi

Trying to install pimatic on raspi I'm stuck at cross-spawn, please excuse if this is the wrong place to ask:

npm install pimatic --production
npm http GET http://registry.npmjs.org/socket.io
npm http GET http://registry.npmjs.org/cross-spawn
npm http 200 http://registry.npmjs.org/cross-spawn
npm http 200 http://registry.npmjs.org/socket.io
npm http GET http://registry.npmjs.org/socket.io/-/socket.io-1.0.6.tgz
npm http 200 http://registry.npmjs.org/socket.io/-/socket.io-1.0.6.tgz
npm ERR! Error: No compatible version found: cross-spawn@'^0.2.3'
npm ERR! Valid install targets:
npm ERR! ["0.1.0","0.1.1","0.1.2","0.1.3","0.1.4","0.1.5","0.1.6","0.1.7","0.2.0","0.2.1","0.2.2","0.2.3"]
npm ERR!     at installTargetsError (/opt/node/lib/node_modules/npm/lib/cache.js:709:10)
npm ERR!     at /opt/node/lib/node_modules/npm/lib/cache.js:631:10
npm ERR!     at saved (/opt/node/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:138:7)
npm ERR!     at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Linux 3.12.24+
npm ERR! command "/opt/node/bin/node" "/opt/node/bin/npm" "install" "pimatic" "--production"
npm ERR! cwd /home/pi/pimatic
npm ERR! node -v v0.10.8
npm ERR! npm -v 1.2.23
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/pi/pimatic/npm-debug.log
npm ERR! not ok code 0

An in-range update of rimraf is breaking the build 🚨

Version 2.6.0 of rimraf just got published.

Branch Build failing 🚨
Dependency rimraf
Current Version 2.5.4
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As rimraf is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build is in progress Details

  • ❌ continuous-integration/appveyor/branch AppVeyor build failed Details

Commits

The new version differs by 5 commits .

  • 5b661e4 v2.6.0
  • c09915f update tap
  • d53235d Make rimraf.sync 10000% more reliable on Windows
  • e8b10a7 Retry on EBUSY et al on non-windows platforms as well
  • 0fac5f7 Add --no-glob option to cli

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Child process hangs

I'm using the library to execute a command in terminal:

process = spawn(command, params, options);
process.stdout.on('data', onLine);
process.stderr.on('data', onLine);
process.on('error', onError);
process.on('close', onClose);

It enters onLine several times with the output, but then just hangs and does nothing (no exit, no error). What are the possible reasons for that? Is that a bug?

If I execute the command in Terminal, everything's fine. The command is linking a module to react native application (react-native link).

Does not return error ENOENT when program not found on Windows

Thanks for developing cross-spawn! It is disappointing that Node.js does not support this out of the box, and your package provides something of great value to those developing packages that require support for Windows.


Normally, when spawn cannot find the program to be executed it returns an error ENOENT. However, since this command is wrapped in cmd.exe it no longer does that, and instead returns an error generated by cmd.exe and has returnCode=1 and stderr in the form β€œcommand” is not recognized as an internal or external command, operable program or batch file.

My workaround was to check if returnCode equals 1 (non-zero) and if the stderr message contains similar text, such as the part: is not recognized as an internal or external command.

I am using it here for my package Atom Beautify: Glavin001/atom-beautify@57ffe75

Please let me know what you think, and if I should submit a Pull Request with the workaround I described above.

spawn inputs console warnings into stdout stream

Hello,
I got here because I'm trying to convert pdf files to images using graphicsmagic. The thing is that PDF files exported with Microsoft word on Mac OS X, have some weird thing and the command of graphicsmagick throws a warning in the console. The issue here is that that warning printed in the console is attached to the stdout from this library causing that the resulting file is corrupted (has the warning in the beginning of the file). And I've found no way of fixing this issue. Any ideas?

Failing when trying to run a git command

Using yeoman, which uses node-cross-spawn as dependency, I'm trying to start a git repo when scaffolding an application with a yeoman custom generator, this is what I got at the install step:

  install: function () {
    this.installDependencies();
    this.spawnCommand('npm', ['i', '--save' , 'express', 'mongodb', 'mongoose', 'lodash', 'bluebird', 'async', 'morgan']);
    this.spawnCommand('git' ['init']); // Here it fails
    this.spawnCommand('git', ['add', '.']);
    this.spawnCommand('git', ['commit', '-am', '"yo scaffolded app"']);
  }

However when trying to run this I get:

events.js:85
      throw er; // Unhandled 'error' event
            ^
TypeError: Bad argument
    at TypeError (native)
    at ChildProcess.spawn (child_process.js:1136:26)
    at Object.exports.spawn (child_process.js:995:9)
    at spawn (/storage/home/dev/generator-koala/node_modules/yeoman-generator/node_modules/cross-spawn/index.js:87:19)
    at spawnCommand (/storage/home/dev/generator-koala/node_modules/yeoman-generator/lib/actions/spawn_command.js:17:10)
    at module.exports.yeoman.generators.Base.extend.install (/storage/home/dev/generator-koala/generators/app/index.js:72:10)
    at /storage/home/dev/generator-koala/node_modules/yeoman-generator/lib/base.js:421:16
    at processImmediate [as _immediateCallback] (timers.js:367:17)

I do have git installed, how should I fix this?

executing rvm within normal bash conditions

I'm trying to execute a command in an rvm environment. To do so, I first need to execute rvm env --path -- ruby-version to yield the file with environment variables that should be sourced. The problem is that this command always returns the global environment, instead of the local environment based on the cwd.

I have verified that the cwd is correct, as well as verifying the output via commandline.

Script:

#!/usr/bin/env bash

ENV_RVM=`rvm env --path --ruby-version`
echo "RVM at $ENV_RVM from `pwd`"
source $ENV_RVM

#rails runner $1

Command line results:
RVM at /Users/kross/.rvm/environments/ruby-2.2.2@af_core from /Users/kross/projects/af_core/spec/dummy
spawn.sync results:
RVM at /Users/kross/.rvm/environments/ruby-2.2.2 from /Users/kross/projects/af_core/spec/dummy

Any thoughts on options I am missing to get RVM to behave as it does on command line?

Command escaping doesn't work on Windows when there's a space in the path

var spawn = require('cross-spawn'); // version 0.2.6

// var command = "node"; // works fine
var command = "c:\\Program Files\\iojs\\node.exe";
// fails even though path is valid
// error is Cannot find module 'D:\Dev\test\Files\iojs\node.exe'
// when executed from 'D:\Dev\test\' directory

var args = ["--version"];

var spawned = spawn(command, args);

spawned.stdout.on('data', function (data) {
  console.log('stdout: ' + data);
});

spawned.stderr.on('data', function (data) {
  console.log('stderr: ' + data);
});

spawned.on('close', function (code) {
  console.log('child process exited with code ' + code);
});

Cannot resolve dependency 'spawn-sync'

You require spawn-sync:

 /Users/jerrygreen/projects/project_name/node_modules/cross-spawn/index.js:32:34: Cannot resolve dependency 'spawn-sync'
  30 |     if (!cpSpawnSync) {
  31 |         try {
> 32 |             cpSpawnSync = require('spawn-sync');  // eslint-disable-line global-require
     |                                   ^
  33 |         } catch (ex) {
  34 |             throw new Error(
  35 |                 'In order to use spawnSync on node 0.10 or older, you must ' +

But here's your dependencies:

[email protected], cross-spawn@^5.1.0:
  version "5.1.0"
  resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
  dependencies:
    lru-cache "^4.0.1"
    shebang-command "^1.2.0"
    which "^1.2.9"

There's no such thing as spawn-sync. Wuuut?

Support spawnSync

Node 0.12 now has spawnSync in addition to spawn. It would be great it node-cross-spawn supported this new method.

path.normalize(command) breaks local command on rebased cwd

Problem

The recent ginormous v6 commit introduced an unconditional path.normalize() wrapping the command, which breaks spawn('./foo', { cwd: 'subdir' ):

command: path.normalize(command),

I can't say what bug it was intended to fix, as the giant commit perverts all useful context. It is definitely breaking posix "local relative on rebased cwd" calls.

Reproduction

Async vs sync makes no difference, but the sync calls are easier to demonstrate.

subdir/foo:

#!/usr/bin/env node
console.log("foo");

test.js:

const path = require('path');
const childProcess = require('child_process');
const spawn = require('cross-spawn');

const cmd = './foo';
const opts = { cwd: path.resolve(__dirname, 'subdir') };

// works
childProcess.spawnSync(cmd, opts) // stdout: "foo"

// fails
spawn.sync(cmd, opts) // throws ENOENT "foo"

Upgrading cross-spawn to v6 in https://github.com/yargs/yargs current master with no other changes will demonstrate this "in the wild".

yargs test failure log
  485 passing (3s)
  10 failing

  1) integration tests should run as a shell script with no arguments:
     Uncaught Error: spawn bin.js ENOENT
      at _errnoException (util.js:1024:11)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
      at onErrorNT (internal/child_process.js:372:16)
      at _combinedTickCallback (internal/process/next_tick.js:138:11)
      at process._tickCallback (internal/process/next_tick.js:180:9)

  2) integration tests should run as a shell script with arguments:
     Uncaught Error: spawn bin.js ENOENT
      at _errnoException (util.js:1024:11)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
      at onErrorNT (internal/child_process.js:372:16)
      at _combinedTickCallback (internal/process/next_tick.js:138:11)
      at process._tickCallback (internal/process/next_tick.js:180:9)

  3) integration tests allows --help to be completed without returning help message:
     Uncaught Error: spawn bin.js ENOENT
      at _errnoException (util.js:1024:11)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
      at onErrorNT (internal/child_process.js:372:16)
      at _combinedTickCallback (internal/process/next_tick.js:138:11)
      at process._tickCallback (internal/process/next_tick.js:180:9)

  4) integration tests flushes all output when --help is executed:
     Uncaught Error: spawn issue-497.js ENOENT
      at _errnoException (util.js:1024:11)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
      at onErrorNT (internal/child_process.js:372:16)
      at _combinedTickCallback (internal/process/next_tick.js:138:11)
      at process._tickCallback (internal/process/next_tick.js:180:9)

  5) integration tests correctly fills positional command args with preceding option:
     Uncaught Error: spawn opt-assignment-and-positional-command-arg.js ENOENT
      at _errnoException (util.js:1024:11)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
      at onErrorNT (internal/child_process.js:372:16)
      at _combinedTickCallback (internal/process/next_tick.js:138:11)
      at process._tickCallback (internal/process/next_tick.js:180:9)

  6) integration tests correctly fills positional command args with = assignment in preceding option:
     Uncaught Error: spawn opt-assignment-and-positional-command-arg.js ENOENT
      at _errnoException (util.js:1024:11)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
      at onErrorNT (internal/child_process.js:372:16)
      at _combinedTickCallback (internal/process/next_tick.js:138:11)
      at process._tickCallback (internal/process/next_tick.js:180:9)

  7) integration tests load root package.json version # defaults to appropriate version # when yargs is installed normally:
     Uncaught Error: spawn normal-bin.js ENOENT
      at _errnoException (util.js:1024:11)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
      at onErrorNT (internal/child_process.js:372:16)
      at _combinedTickCallback (internal/process/next_tick.js:138:11)
      at process._tickCallback (internal/process/next_tick.js:180:9)

  8) integration tests load root package.json version # defaults to appropriate version # when yargs is symlinked:
     Uncaught Error: spawn symlink-bin.js ENOENT
      at _errnoException (util.js:1024:11)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
      at onErrorNT (internal/child_process.js:372:16)
      at _combinedTickCallback (internal/process/next_tick.js:138:11)
      at process._tickCallback (internal/process/next_tick.js:180:9)

  9) integration tests load root package.json parser settings reads parser config settings when yargs is installed normally:
     Uncaught Error: spawn normal-bin.js ENOENT
      at _errnoException (util.js:1024:11)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
      at onErrorNT (internal/child_process.js:372:16)
      at _combinedTickCallback (internal/process/next_tick.js:138:11)
      at process._tickCallback (internal/process/next_tick.js:180:9)

  10) integration tests load root package.json parser settings reads parser config settings when yargs is installed as a symlink:
     Uncaught Error: spawn symlink-bin.js ENOENT
      at _errnoException (util.js:1024:11)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
      at onErrorNT (internal/child_process.js:372:16)
      at _combinedTickCallback (internal/process/next_tick.js:138:11)
      at process._tickCallback (internal/process/next_tick.js:180:9)

Possible issue with pre-commit + npm + spawn env

When cross-spawn is invoked in a pre-commit hook code by husky, if the process.env is used, npm command errors out inexplicably on windows:

Ξ» git commit
husky > npm run -s precommit (node v8.5.0)

,,

husky > pre-commit hook failed (add --no-verify to bypass)

On manually removing the silent(-s) flag in the husky pre-commit hook(subl ./.git/hooks/pre-commit), we can see the error logs:

npm error logs
Ξ» git commit
husky > npm run precommit (node v8.5.0)


> [email protected] precommit E:\Projects\experiments\test-cross-spawn-env
> npm run spawn


> [email protected] spawn E:\Projects\experiments\test-cross-spawn-env
> node spawn.js

npm WARN invalid config access=undefined
npm WARN invalid config also=undefined
npm WARN invalid config https-proxy=undefined
npm WARN invalid config Must be a full url with 'http://'
npm WARN invalid config init-author-url=undefined
npm WARN invalid config Must be a full url with 'http://'
npm WARN invalid config only=undefined
npm WARN invalid config proxy=undefined
npm WARN invalid config Must be a full url with 'http://'
npm WARN onload-script failed to require onload script undefined
npm WARN onload-script Error: Cannot find module 'undefined'
npm WARN onload-script     at Function.Module._resolveFilename (module.js:527:15)
npm WARN onload-script     at Function.Module._load (module.js:476:23)
npm WARN onload-script     at Module.require (module.js:568:17)
npm WARN onload-script     at require (internal/module.js:11:18)
npm WARN onload-script     at cb (C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:225:11)
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:356:16
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:81:7
npm WARN onload-script     at Array.forEach (<anonymous>)
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:80:13
npm WARN onload-script     at f (C:\nvm\v8.5.0\node_modules\npm\node_modules\once\once.js:25:25)
npm WARN onload-script  { Error: Cannot find module 'undefined'
npm WARN onload-script     at Function.Module._resolveFilename (module.js:527:15)
npm WARN onload-script     at Function.Module._load (module.js:476:23)
npm WARN onload-script     at Module.require (module.js:568:17)
npm WARN onload-script     at require (internal/module.js:11:18)
npm WARN onload-script     at cb (C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:225:11)
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:356:16
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:81:7
npm WARN onload-script     at Array.forEach (<anonymous>)
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:80:13
npm WARN onload-script     at f (C:\nvm\v8.5.0\node_modules\npm\node_modules\once\once.js:25:25)
npm WARN onload-script   stack: 'Error: Cannot find module \'undefined\'\n    at Function.Module._resolveFilename (module.js:527:15)\n    at Function.Module._load (module.js:476:23)\n    at Module.require (module.js:568:17)\n    at require (internal/module.js:11:18)\n    at cb (C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\npm.js:225:11)\n
    at C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\npm.js:356:16\n    at C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\config\\core.js:81:7\n    at Array.forEach (<anonymous>)\n    at C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\config\\core.js:80:13\n    at f (C:\\nvm\\v8.5.0\\node_modules\\npm\\node_modules\\once\\once.js:25:25)',
npm WARN onload-script   code: 'MODULE_NOT_FOUND' }
npm WARN invalid config access=undefined
npm WARN invalid config also=undefined
npm WARN invalid config https-proxy=undefined
npm WARN invalid config Must be a full url with 'http://'
npm WARN invalid config init-author-url=undefined
npm WARN invalid config Must be a full url with 'http://'
npm WARN invalid config only=undefined
npm WARN invalid config proxy=undefined
npm WARN invalid config Must be a full url with 'http://'
npm WARN onload-script failed to require onload script undefined
npm WARN onload-script Error: Cannot find module 'undefined'
npm WARN onload-script     at Function.Module._resolveFilename (module.js:527:15)
npm WARN onload-script     at Function.Module._load (module.js:476:23)
npm WARN onload-script     at Module.require (module.js:568:17)
npm WARN onload-script     at require (internal/module.js:11:18)
npm WARN onload-script     at cb (C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:225:11)
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:356:16
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:81:7
npm WARN onload-script     at Array.forEach (<anonymous>)
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:80:13
npm WARN onload-script     at f (C:\nvm\v8.5.0\node_modules\npm\node_modules\once\once.js:25:25)
npm WARN onload-script  { Error: Cannot find module 'undefined'
npm WARN onload-script     at Function.Module._resolveFilename (module.js:527:15)
npm WARN onload-script     at Function.Module._load (module.js:476:23)
npm WARN onload-script     at Module.require (module.js:568:17)
npm WARN onload-script     at require (internal/module.js:11:18)
npm WARN onload-script     at cb (C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:225:11)
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:356:16
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:81:7
npm WARN onload-script     at Array.forEach (<anonymous>)
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:80:13
npm WARN onload-script     at f (C:\nvm\v8.5.0\node_modules\npm\node_modules\once\once.js:25:25)
npm WARN onload-script   stack: 'Error: Cannot find module \'undefined\'\n    at Function.Module._resolveFilename (module.js:527:15)\n    at Function.Module._load (module.js:476:23)\n    at Module.require (module.js:568:17)\n    at require (internal/module.js:11:18)\n    at cb (C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\npm.js:225:11)\n
    at C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\npm.js:356:16\n    at C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\config\\core.js:81:7\n    at Array.forEach (<anonymous>)\n    at C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\config\\core.js:80:13\n    at f (C:\\nvm\\v8.5.0\\node_modules\\npm\\node_modules\\once\\once.js:25:25)',
npm WARN onload-script   code: 'MODULE_NOT_FOUND' }

> [email protected] hello E:\Projects\experiments\test-cross-spawn-env
> node index.js

npm ERR! file undefined
npm ERR! path undefined
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn undefined
npm ERR! [email protected] hello: `node index.js`
npm ERR! spawn undefined ENOENT
npm ERR!
npm ERR! Failed at the [email protected] hello script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! code ELIFECYCLE
npm ERR! errno -4058
npm ERR! [email protected] hello: `node index.js`
npm ERR! Exit status -4058
npm ERR!
npm ERR! Failed at the [email protected] hello script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\suhas.karanth\AppData\Roaming\npm-cache\_logs\2017-09-21T04_55_49_244Z-debug.log
,,
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] spawn: `node spawn.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] spawn script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\suhas.karanth\AppData\Roaming\npm-cache\_logs\2017-09-21T04_55_49_341Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] precommit: `npm run spawn`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] precommit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\suhas.karanth\AppData\Roaming\npm-cache\_logs\2017-09-21T04_55_49_408Z-debug.log

husky > pre-commit hook failed (add --no-verify to bypass)

I faced and fixed these issues in a couple of places. The solution was to filter process.env for undefined values:

Repo Issue PR
kentcdodds/kcd-scripts kentcdodds/kcd-scripts#4 kentcdodds/kcd-scripts#5
ta2edchimp/opt-cli sezna/nps#155 ta2edchimp/opt-cli#213

I have created a repo for demonstrating the issue - https://github.com/sudo-suhas/test-cross-spawn-env

I am not entirely sure if this is a problem which cross-spawn should handle. Thoughts?

cc @kentcdodds

Extract an async only version

As this module is shipped with ember-cli and several ember-cli users have issues to compile native c extensions it would be nice to have the async version available as a separate module

Related: #18

An in-range update of eslint is breaking the build 🚨

Version 3.13.1 of eslint just got published.

Branch Build failing 🚨
Dependency eslint
Current Version 3.13.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As eslint is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/appveyor/branch Waiting for AppVeyor build to complete Details

  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v3.13.1
  • 3fc4e3f Fix: prefer-destructuring reporting compound assignments (fixes #7881) (#7882) (Teddy Katz)
  • f90462e Fix: no-extra-label autofix should not remove labels used elsewhere (#7885) (Teddy Katz)
Commits

The new version differs by 4 commits .

  • 7f8393c 3.13.1
  • 91883bf Build: package.json and changelog update for 3.13.1
  • 3fc4e3f Fix: prefer-destructuring reporting compound assignments (fixes #7881) (#7882)
  • f90462e Fix: no-extra-label autofix should not remove labels used elsewhere (#7885)

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Please add switch to opt-out of special ENOENT behavior for Windows if desired

In my use of cross-spawn (actually via the cross-env package), I have discovered that there is some special error-emission behavior (apparently for Windows and cmd.exe?) implemented by the enoent.js source file, which is described on the following line:

https://github.com/moxystudio/node-cross-spawn/blob/master/lib/enoent.js#L25

This line also contains a comment which refers the original issue.

Basically, the special behavior is: If the spawned process exits with 1 and the command line cannot be found in file system, emit an Error describing an ENOENT error condition (i.e., "command not found").

(It may be helpful to familiarize yourself with the source code and the details of the original issue before reading on.)

But, there is (and IMO has always been) a problem: The logic in enoent.js assumes that exit code 1 should aways trigger the special ENOENT error-emission behavior... but the assumptions behind that special behavior are only correct in certain cases, wrong in others.

Firstly, cmd.exe may not even be in the picture, so any behavior based on the assumption that it is, is flawed. (Windows has a new shell, now the default, called PowerShell.exe, so the chances that cmd.exe is not being used is actually quite high.)

Secondly, there are many used-cases in which an exit code of 1 does not implicitly mean "command not found". Even with cmd.exe this could easily be the case... any Windows command script, or process launched by the script, could simply choose to exit the script with 1, or any other code, for any purpose.

Thirdly, the command passed to cross-spawn may not be an actual file-system location that can be "verified" exists or not. This is especially true with PowerShell, since the command might refer to a "cmdlet" (callable entities which are named independently of the file system) that ran successfully, but simply chose to exit with 1.

In short, this special hard-coded behavior can easily do the wrong thing. For some cases, it may be desirable to convert exit code 1 + "command not found" into an emission of ENOENT, but in other cases, this logic is wrong, and only creates confusion and annoyance.

Case in point: Unit test frameworks (mocha for example) exit with the number of failed tests (i.e., 0 for success, any other number for failure). When cross-spawn is used in such a case, a confusing ENOENT error occurs whenever 1 test fails, but not when 2 more tests fail.

For real-world cases like this, where the special ENOENT behavior is not appropriate, would you consider adding a flag to allow the caller to opt-out of the special logic? That is, just pass any exit code straight through. (Better yet, IMO, place the current special behavior behind an opt-in flag instead.)

Thanks.

Drop support for versions below Node.js 6

Something for the future, I was looking into reducing my CLI tool size and noticed the semver package at the top when sorting by size.

When going with Node.js 6 and higher two dependencies, semver and nice-try are not needed anymore since they are used only once for feature detection here:

const supportsShellOption = niceTry(() => semver.satisfies(process.version, '^4.8.0 || ^5.7.0 || >= 6.0.0', true)) || false;

Unable to pipe stdout and stderr to a file

Hi

I'm not able to pipe the stfout/err to a file. This is the sample im trying:

var spawn = require('cross-spawn),
    out = fs.openSync('run.log', 'a');
   var childProcess =   spawn('myserver', ['run'], {
      stdio: [ 'ignore', out, out ], // piping stdout and stderr to run.log
      detached: true
    });
    childProcess.unref();
    sleep(2300); // delay needed for the "myserver run" to start
    var run_output = fs.readFileSync(path.join(working_dir, 'run.log')).toString();
    expect(run_output).includes("listening on 100101");

On running this i see a new command prompt popping up, with the "listening on 100101" message.
And run.log is empty.

Ideally, I would expect it to just pipe the output to run.log and NOT bring up a new cmd prompt.

Could you please help me with this?

Im running it on

Windows 10
"mocha": "^2.4.5"

Thanks
Ramya

Improper documentation

Documentation do not provide sufficient information on what is the parameter used under spawn command. The document is only for those who are into javascript for few years. Not recommended for new buddies or new learners

spawn.sync result object has `result.status == 0` for `result.signal == SIGKILL`

From https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/bin/react-scripts.js

#!/usr/bin/env node
var spawn = require('cross-spawn');
var script = process.argv[2];
var args = process.argv.slice(3);
...
  var result = spawn.sync(
    'node',
    [require.resolve('../scripts/' + script)].concat(args),
    {stdio: 'inherit'}
  );
  console.log(result.signal);
  console.log(result.status);
  process.exit(result.status);

Result when the child process is hit with kill -9:

SIGKILL
0

result.status should be equal to 9.

Add `kill` function to spawn object

Originally I wanted to extract this as a separate module, but I think it actually makes most sense to simply add it to cross-spawn itself. Would you be interested? The win32 version of the function would be:

function kill() {
  crossSpawn("taskkill", ["/F", "/T", "/PID", this.pid])
}

And the posix:

const getDescendentProcessInfo = require("ps-tree")

function kill() {
    getDescendentProcessInfo(this.pid, (err, descendent) => {
        if (err) {
            return
        }

        descendent.forEach(({PID: pid}) => {
            try {
                process.kill(pid)
            }
            catch (_err) {
                // ignore.
            }
        })
    })
}

Would you be willing to accept a PR for this?

cc @mysticatea

An in-range update of eslint is breaking the build 🚨

Version 3.12.1 of eslint just got published.

Branch Build failing 🚨
Dependency eslint
Current Version 3.12.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As eslint is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • βœ… continuous-integration/travis-ci/push The Travis CI build passed Details

  • ❌ continuous-integration/appveyor/branch AppVeyor build failed Details

Release Notes v3.12.1
  • 0ad4d33 Fix: indent regression with function calls (fixes #7732, fixes #7733) (#7734) (Teddy Katz)
  • ab246dd Docs: Rules restricting globals/properties/syntax are linked together (#7743) (Kevin Partington)
  • df2f115 Docs: Add eslint-config-mdcs to JSCS Migration Guide (#7737) (Joshua Koo)
  • 4b77333 Build: avoid creating broken rule links in the changelog (#7731) (Teddy Katz)
Commits

The new version differs by 6 commits .

  • 9679daa 3.12.1
  • 8a31bc8 Build: package.json and changelog update for 3.12.1
  • 0ad4d33 Fix: indent regression with function calls (fixes #7732, fixes #7733) (#7734)
  • ab246dd Docs: Rules restricting globals/properties/syntax are linked together (#7743)
  • df2f115 Docs: Add eslint-config-mdcs to JSCS Migration Guide (#7737)
  • 4b77333 Build: avoid creating broken rule links in the changelog (#7731)

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Paths with NTFS JUNCTIONS (links)

If I pass a file such as node_modules\foo\index.js as the 2nd arg to spawn.sync, where foo is a JUNCTION (NTFS link) to another folder then I get the error

"The system cannot find the file specified!"

It's obviously not following through the link

This situation occurs when locally developing a package andwanting to run somehting in it.

An in-range update of rimraf is breaking the build 🚨

Version 2.6.2 of rimraf just got published.

Branch Build failing 🚨
Dependency rimraf
Current Version 2.6.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As rimraf is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • βœ… continuous-integration/travis-ci/push The Travis CI build passed Details
  • ❌ continuous-integration/appveyor/branch AppVeyor build failed Details

Commits

The new version differs by 2 commits.

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Can't seem to install

npm WARN package.json [email protected] 'repositories' (plural) Not supported.
npm WARN package.json Please pick one as the 'repository' field
npm http GET https://registry.npmjs.org/webshot
npm http 200 https://registry.npmjs.org/webshot
npm http GET https://registry.npmjs.org/graceful-fs
npm http GET https://registry.npmjs.org/cross-spawn
npm http GET https://registry.npmjs.org/phantomjs
npm http GET https://registry.npmjs.org/tmp
npm http 304 https://registry.npmjs.org/cross-spawn
npm http 304 https://registry.npmjs.org/graceful-fs
npm http 304 https://registry.npmjs.org/phantomjs
npm http 304 https://registry.npmjs.org/tmp
npm ERR! Error: No compatible version found: cross-spawn@'^0.2.3'
npm ERR! Valid install targets:
npm ERR! ["0.1.0","0.1.1","0.1.2","0.1.3","0.1.4","0.1.5","0.1.6","0.1.7","0.2.0","0.2.1","0.2.2","0.2.3","0.2.4","0.2.5","0.2.6"]
npm ERR! at installTargetsError (/service/app/node_modules/npm/lib/cache.js:719:10)
npm ERR! at /service/app/node_modules/npm/lib/cache.js:641:10
npm ERR! at saved (/service/app/node_modules/npm/node_modules/npm-registry-client/lib/get.js:138:7)
npm ERR! at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! [email protected]

npm ERR! System Linux 2.6.32-358.6.2.el6.x86_64
npm ERR! command "/service/app/node-v0.10.12/bin/node" "/usr/local/bin/npm" "install" "webshot"
npm ERR! cwd /home/lance
npm ERR! node -v v0.10.12
npm ERR! npm -v 1.2.32
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/lance/npm-debug.log
npm ERR! not ok code 0

`which` bin conflicts with native `which` when running npm scripts...

hey there πŸ‘‹

thanks for a very helpful lib πŸ™πŸ‘

i'm coming here by way of execa having hit upon a fairly gnarly edge-case:

let's say you have a js script that tries to execute a file via execa and the file it executes runs which. if you run that script via npm - e.g. npm run my-script.js - cross-spawn's which dependency overrides the native one and can produce different / unexpected results.

this is due to the which dependency (source) installing a which bin into node_modules/.bin (source) combined with the behavior of npm run:

In addition to the shell’s pre-existing PATH, npm run adds node_modules/.bin to the PATH provided to scripts

(source)

in my case, i was trying to run a script file on windows using cygwin. within powershell, running:

bash -c "which make"

gave me:

/usr/bin/make

but doing the same using a node script run via npm run:

const { stdout } = await execa('bash -c "which make");

gave me:

C:\cygwin\bin\make.EXE

the later uses a windows-style path b/c it relies on node's view of the environment (vs. cygwin' bash's view).

it gets worse when you try to look for an executable script that is not an .exe - e.g. bash -c "which libtool". in this case, the node / npm version of which returns nothing while the native version correctly locates the script in /usr/bin/libtool

my work-around at the moment is to simply not use npm run to execute my script. naively, i wonder if there's a way to avoid having the which dependency install a bin (since it looks like cross-spawn only ever uses the dependency via require('which').

πŸ€·β€β™‚

Wrong detection under yarn on windows

Test suite:

  • package.json
{
	"name": "test",
	"version": "1.0.0",
	"main": "index.js",
	"license": "MIT",
	"scripts": {
		"test": "node test.js"
	},
	"dependencies": {
		"cross-spawn": "^6.0.5"
	}
}
  • test.js
var crossSpawn = require('cross-spawn');
var cmd = crossSpawn.sync('yarn', ['--version'], {
	stdio: 'inherit',
});
console.log('yarn --version return:', cmd.status);
console.log('path of child process:', cmd.options.envPairs.filter(e => /^path=/i.test(e)));
process.exit(cmd.status);

command to run

yarn install
yarn node test.js
yarn run test

my output

PS D:\Projects\test> yarn node test.js
yarn node v1.12.1
1.12.1
yarn --version return: 0
path of child process: [ 'Path=xxxxxxxxxxxxxxx' ]
Done in 0.83s.

PS D:\Projects\test> yarn run test
yarn run v1.12.1
$ node test.js
The filename, directory name, or volume label syntax is incorrect.
yarn --version return: 1
path of child process: [ 'Path=A:\\USR-TMP\\yarn--1541088945270-0.3043972176672871;xxxxxxxxxxxxxxxxxxxx' ]
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

generated yarn and node in my $TEMP folder, contains bash script.

problem

this is also a yarn issue.
But yarn not want to fool this module, so the detect logic must have a bug. ( Or maybe there is a bug in nodejs core 🀣 )

Does not work inside workers threads

I am trying to use execa by running code in worker threads, and it is generating the TypeError error [ERR_WORKER_UNSUPPORTED_OPERATION]: process.chdir () is not supported in workers.

process.chdir(cwd)

Commands with spaces fail with shell: true

Commands with spaces fail with shell: true, but work if it's false. node developers say fixing this from their side would break other things: nodejs/node#7367 . Should this be fixed in cross-spawn? What do you think?

> require('cross-spawn').spawn('C:\\Program Files\\nodejs\\node.exe', [], {shell:true})
undefined
> Error: spawn C:\Program Files\nodejs\node.exe ENOENT
    at notFoundError (C:\Users\redacted\node_modules\cross-spawn\lib\enoent.js:11:11)
    at verifyENOENT (C:\Users\redacted\node_modules\cross-spawn\lib\enoent.js:46:16)
    at ChildProcess.cp.emit (C:\Users\redacted\node_modules\cross-spawn\lib\enoent.js:33:19)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
> require('cross-spawn').spawn('C:\\Program Files\\nodejs\\node.exe', [], {shell:false})
ChildProcess {
...

An in-range update of eslint is breaking the build 🚨

Version 3.15.0 of eslint just got published.

Branch Build failing 🚨
Dependency eslint
Current Version 3.14.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As eslint is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/appveyor/branch Waiting for AppVeyor build to complete Details

  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v3.15.0
  • f2a3580 Fix: no-extra-parens incorrect precedence (fixes #7978) (#7999) (alberto)
  • d6b6ba1 Fix: no-var should fix ForStatement.init (#7993) (Toru Nagashima)
  • 99d386d Upgrade: Espree v3.4.0 (#8019) (Kai Cataldo)
  • 42390fd Docs: update README.md for team (#8016) (Toru Nagashima)
  • d7ffd88 Chore: enable template-tag-spacing on ESLint codebase (#8005) (Teddy Katz)
  • f2be7e3 Docs: Fix typo in object-curly-newline.md (#8002) (Danny Andrews)
  • df2351a Docs: Fix misleading section in brace-style documentation (#7996) (Teddy Katz)
  • 5ae6e00 Chore: avoid unnecessary feature detection for Symbol (#7992) (Teddy Katz)
  • 5d57c57 Chore: fix no-else-return lint error (refs #7986) (#7994) (Vitor Balocco)
  • 62fb054 Chore: enable no-else-return on ESLint codebase (#7986) (Teddy Katz)
  • c59a0ba Update: add ignoreRestSiblings option to no-unused-vars (#7968) (Zack Argyle)
  • 5cdfa99 Chore: enable no-unneeded-ternary on ESLint codebase (#7987) (Teddy Katz)
  • fbd7c13 Update: ensure operator-assignment handles exponentiation operators (#7970) (Teddy Katz)
  • c5066ce Update: add "variables" option to no-use-before-define (fixes #7111) (#7948) (Teddy Katz)
  • 09546a4 New: template-tag-spacing rule (fixes #7631) (#7913) (Jonathan Wilsson)
Commits

The new version differs by 17 commits .

  • 8ea98f9 3.15.0
  • 77b5cb7 Build: package.json and changelog update for 3.15.0
  • f2a3580 Fix: no-extra-parens incorrect precedence (fixes #7978) (#7999)
  • d6b6ba1 Fix: no-var should fix ForStatement.init (#7993)
  • 99d386d Upgrade: Espree v3.4.0 (#8019)
  • 42390fd Docs: update README.md for team (#8016)
  • d7ffd88 Chore: enable template-tag-spacing on ESLint codebase (#8005)
  • f2be7e3 Docs: Fix typo in object-curly-newline.md (#8002)
  • df2351a Docs: Fix misleading section in brace-style documentation (#7996)
  • 5ae6e00 Chore: avoid unnecessary feature detection for Symbol (#7992)
  • 5d57c57 Chore: fix no-else-return lint error (refs #7986) (#7994)
  • 62fb054 Chore: enable no-else-return on ESLint codebase (#7986)
  • c59a0ba Update: add ignoreRestSiblings option to no-unused-vars (#7968)
  • 5cdfa99 Chore: enable no-unneeded-ternary on ESLint codebase (#7987)
  • fbd7c13 Update: ensure operator-assignment handles exponentiation operators (#7970)

There are 17 commits in total. See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of babel-preset-moxy is breaking the build 🚨

Version 2.3.4 of babel-preset-moxy was just published.

Branch Build failing 🚨
Dependency babel-preset-moxy
Current Version 2.3.3
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

babel-preset-moxy is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • βœ… continuous-integration/appveyor/branch: AppVeyor build succeeded (Details).
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 2 commits.

  • d94c357 chore(release): 2.3.4
  • 722526c fix: fix dev errors when using transform-react-inline-elements

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Remove `spawn-sync`

Can we remove the spawn-sync dependency? Node 0.10 will be completely unsupported in about 6 months (even including security releases). It's going to be completely dead soon.

It's a huge burden to maintainers to answer users questions about the native dependency errors in the npm install output. Even though we know it's harmless output, since the dependency is optional, users don't. So, we see a lot of opened issues about this.

Here's a proposal:

  • Remove spawn-sync, effectively dropping 0.10 support
  • Publish this in a new major version. (Users that need 0.10 support can just lock to the previous version.)

Related issues:
#18
websockets/ws#577

How to store the value of a command?

Hello,

Actually I'm building a CLI app, I want to ask users some question, like project name or project author. And I want to give them default value of project author as git user.name.

My code below:

const spawn = require('cross-spawn')
const { red } = require('chalk')

const { error } = console

const child = spawn('git', ['config', 'user.name'], { stdio: 'inherit' })

child.on('close', code => {
  if (code !== 0) {
    error(red(`Process exited with error code ${code}`))
  }
})

This code is perfectly printing the git user.name in the console but I want to store it in a variable or something like that so I can use it in the future.

Note: My app is a lot like npm init or yarn init command. It just asks some questions with some default values and creates a config file.

Thank you πŸ™

Make cmd optional

child_process.spawn recently got a shell option that spawns cmd.exe for you on Windows, pretty much the way cross-spawn does. However, as discussed in nodejs/node#6671 and nodejs/node#6784, it signifcantly impacts performance.

To avoid unnecessarily slowing down the spawn call, I suggested looking at the file extension to determine if a shell is actually required. The PR got rejected, which I understand (see link above), but I think it makes sense to include the same logic in cross-spawn.

Before I actually create a PR, I'd like to test the water first. Do you think it's a good idea?

An in-range update of lru-cache is breaking the build 🚨

Version 4.1.0 of lru-cache just got published.

Branch Build failing 🚨
Dependency lru-cache
Current Version 4.0.2
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

lru-cache is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • βœ… continuous-integration/travis-ci/push The Travis CI build passed Details
  • ❌ continuous-integration/appveyor/branch AppVeyor build failed Details

Commits

The new version differs by 9 commits.

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Setup Windows CI

Travis CI does not support Windows, although how about AppVeyor?

Any other reason why there isn't a Windows CI setup for this project already?

Different escaping between spawn and cross-spawn

I'm trying to use cross-spawn as a drop-in replacement for spawn and execute the following command using the node 6 shell options, but it looks like the escaping in cross-spawn doesn't work the same as on linux.

On linux:

spawn('node', ['-e', 'console.log\\(\\"hello\\"\\)'], { shell: true});
> "test"

On windows:

crossSpawn('node', ['-e', 'console.log\\(\\"hello\\"\\)'], { shell: true});
> [eval]:1
console.log\(\"hello\"\)
        ^^^^
SyntaxError: Unexpected token ILLEGAL
    at Object.exports.runInThisContext (vm.js:53:16)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:409:26)
    at node.js:579:27
    at nextTickCallbackWith0Args (node.js:420:9)
    at process._tickCallback (node.js:349:13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.