Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: moxystudio/node-cross-spawn
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v6.0.5
Choose a base ref
...
head repository: moxystudio/node-cross-spawn
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v7.0.1
Choose a head ref
  • 16 commits
  • 12 files changed
  • 4 contributors

Commits on Mar 3, 2018

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired and has been revoked.
    jhpratt Jacob Pratt
    Copy the full SHA
    8f20cbc View commit details

Commits on Mar 18, 2018

  1. Copy the full SHA
    bbd342b View commit details

Commits on Jul 28, 2018

  1. chore: update dev deps

    satazor committed Jul 28, 2018
    Copy the full SHA
    18ebd93 View commit details

Commits on Sep 11, 2018

  1. chore: update babel preset

    satazor committed Sep 11, 2018
    Copy the full SHA
    6450fe7 View commit details

Commits on Feb 28, 2019

  1. Copy the full SHA
    85339d4 View commit details
  2. Copy the full SHA
    47aff71 View commit details

Commits on Mar 12, 2019

  1. Copy the full SHA
    9c9d627 View commit details

Commits on Mar 13, 2019

  1. chore: fix tests

    satazor committed Mar 13, 2019
    Copy the full SHA
    48bee1d View commit details

Commits on Aug 20, 2019

  1. refactor: drop support for versions below Node.js 8 (#125)

    BREAKING CHANGE: drop support for Node.js < 8
    Siilwyn authored and satazor committed Aug 20, 2019
    Copy the full SHA
    16feb53 View commit details

Commits on Sep 3, 2019

  1. chore: update deps

    satazor committed Sep 3, 2019
    Copy the full SHA
    6fdaf5a View commit details
  2. chore(release): 7.0.0

    satazor committed Sep 3, 2019
    Copy the full SHA
    0e7cd3d View commit details

Commits on Oct 6, 2019

  1. Copy the full SHA
    cfd49c9 View commit details

Commits on Oct 7, 2019

  1. chore: update deps

    André Cruz authored and satazor committed Oct 7, 2019
    Copy the full SHA
    9c7de59 View commit details
  2. chore: fix eslint config

    André Cruz authored and satazor committed Oct 7, 2019
    Copy the full SHA
    2998699 View commit details
  3. Copy the full SHA
    fb5e12c View commit details
  4. chore(release): 7.0.1

    satazor committed Oct 7, 2019
    Copy the full SHA
    aa7f227 View commit details
Showing with 6,916 additions and 5,671 deletions.
  1. +6 −9 .travis.yml
  2. +17 −1 CHANGELOG.md
  3. +5 −3 README.md
  4. +2 −11 appveyor.yml
  5. +1 −35 lib/parse.js
  6. +1 −10 lib/util/readShebang.js
  7. +6 −2 lib/util/resolveCommand.js
  8. +6,847 −5,572 package-lock.json
  9. +25 −24 package.json
  10. +4 −1 test/.babelrc
  11. +1 −2 test/.eslintrc
  12. +1 −1 test/util/run.js
15 changes: 6 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
language: node_js
node_js:
- '4.7'
- '4.8'
- '5.6'
- '5.7'
- '6'
- 'node'
- 'lts/*'
- 8
- 9
- 10
- 12
after_success:
- "npm i codecov"
- "node_modules/.bin/codecov"
- 'npm i codecov'
- 'node_modules/.bin/codecov'
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
# Change Log
# Changelog

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [7.0.1](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.0...v7.0.1) (2019-10-07)


### Bug Fixes

* **core:** support worker threads ([#127](https://github.com/moxystudio/node-cross-spawn/issues/127)) ([cfd49c9](https://github.com/moxystudio/node-cross-spawn/commit/cfd49c9))

## [7.0.0](https://github.com/moxystudio/node-cross-spawn/compare/v6.0.5...v7.0.0) (2019-09-03)


### ⚠ BREAKING CHANGES

* drop support for Node.js < 8

* drop support for versions below Node.js 8 ([#125](https://github.com/moxystudio/node-cross-spawn/issues/125)) ([16feb53](https://github.com/moxystudio/node-cross-spawn/commit/16feb53))

<a name="6.0.5"></a>
## [6.0.5](https://github.com/moxystudio/node-cross-spawn/compare/v6.0.4...v6.0.5) (2018-03-02)

8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# cross-spawn

[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Build status][appveyor-image]][appveyor-url] [![Coverage Status][codecov-image]][codecov-url] [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url] [![Greenkeeper badge][greenkeeper-image]][greenkeeper-url]
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Build status][appveyor-image]][appveyor-url] [![Coverage Status][codecov-image]][codecov-url] [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url]

[npm-url]:https://npmjs.org/package/cross-spawn
[downloads-image]:http://img.shields.io/npm/dm/cross-spawn.svg
@@ -15,16 +15,17 @@
[david-dm-image]:https://img.shields.io/david/moxystudio/node-cross-spawn.svg
[david-dm-dev-url]:https://david-dm.org/moxystudio/node-cross-spawn?type=dev
[david-dm-dev-image]:https://img.shields.io/david/dev/moxystudio/node-cross-spawn.svg
[greenkeeper-image]:https://badges.greenkeeper.io/moxystudio/node-cross-spawn.svg
[greenkeeper-url]:https://greenkeeper.io/

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

@@ -89,6 +90,7 @@ Remember to always test your code on Windows!
`$ npm test`
`$ npm test -- --watch` during development


## License

Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
13 changes: 2 additions & 11 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -4,21 +4,12 @@
init:
- git config --global core.autocrlf input

# If we are running on Node <6, we must install npm v3 otherwise
# there will be intermitent errors when running `npm install`
environment:
matrix:
- nodejs_version: 4.7
npm_version: ^3.0.0
- nodejs_version: 4.8
npm_version: ^3.0.0
- nodejs_version: 5.6
npm_version: ^3.0.0
- nodejs_version: 5.7
npm_version: ^3.0.0
- nodejs_version: 6
- nodejs_version: 8
- nodejs_version: 9
- nodejs_version: 10
- nodejs_version: 12

install:
- ps: Install-Product node $env:nodejs_version
36 changes: 1 addition & 35 deletions lib/parse.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
'use strict';

const path = require('path');
const niceTry = require('nice-try');
const resolveCommand = require('./util/resolveCommand');
const escape = require('./util/escape');
const readShebang = require('./util/readShebang');
const semver = require('semver');

const isWin = process.platform === 'win32';
const isExecutableRegExp = /\.(?:com|exe)$/i;
const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;

// `options.shell` is supported in Node ^4.8.0, ^5.7.0 and >= 6.0.0
const supportsShellOption = niceTry(() => semver.satisfies(process.version, '^4.8.0 || ^5.7.0 || >= 6.0.0', true)) || false;

function detectShebang(parsed) {
parsed.file = resolveCommand(parsed);

@@ -67,35 +62,6 @@ function parseNonShell(parsed) {
return parsed;
}

function parseShell(parsed) {
// If node supports the shell option, there's no need to mimic its behavior
if (supportsShellOption) {
return parsed;
}

// Mimic node shell option
// See https://github.com/nodejs/node/blob/b9f6a2dc059a1062776133f3d4fd848c4da7d150/lib/child_process.js#L335
const shellCommand = [parsed.command].concat(parsed.args).join(' ');

if (isWin) {
parsed.command = typeof parsed.options.shell === 'string' ? parsed.options.shell : process.env.comspec || 'cmd.exe';
parsed.args = ['/d', '/s', '/c', `"${shellCommand}"`];
parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped
} else {
if (typeof parsed.options.shell === 'string') {
parsed.command = parsed.options.shell;
} else if (process.platform === 'android') {
parsed.command = '/system/bin/sh';
} else {
parsed.command = '/bin/sh';
}

parsed.args = ['-c', shellCommand];
}

return parsed;
}

function parse(command, args, options) {
// Normalize arguments, similar to nodejs
if (args && !Array.isArray(args)) {
@@ -119,7 +85,7 @@ function parse(command, args, options) {
};

// Delegate further parsing to shell or non-shell
return options.shell ? parseShell(parsed) : parseNonShell(parsed);
return options.shell ? parsed : parseNonShell(parsed);
}

module.exports = parse;
11 changes: 1 addition & 10 deletions lib/util/readShebang.js
Original file line number Diff line number Diff line change
@@ -6,16 +6,7 @@ const shebangCommand = require('shebang-command');
function readShebang(command) {
// Read the first 150 bytes from the file
const size = 150;
let buffer;

if (Buffer.alloc) {
// Node.js v4.5+ / v5.10+
buffer = Buffer.alloc(size);
} else {
// Old Node.js API
buffer = new Buffer(size);
buffer.fill(0); // zero-fill
}
const buffer = Buffer.alloc(size);

let fd;

8 changes: 6 additions & 2 deletions lib/util/resolveCommand.js
Original file line number Diff line number Diff line change
@@ -7,10 +7,12 @@ const pathKey = require('path-key')();
function resolveCommandAttempt(parsed, withoutPathExt) {
const cwd = process.cwd();
const hasCustomCwd = parsed.options.cwd != null;
// Worker threads do not have process.chdir()
const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined;

// If a custom `cwd` was specified, we need to change the process cwd
// because `which` will do stat calls but does not support a custom cwd
if (hasCustomCwd) {
if (shouldSwitchCwd) {
try {
process.chdir(parsed.options.cwd);
} catch (err) {
@@ -28,7 +30,9 @@ function resolveCommandAttempt(parsed, withoutPathExt) {
} catch (e) {
/* Empty */
} finally {
process.chdir(cwd);
if (shouldSwitchCwd) {
process.chdir(cwd);
}
}

// If we successfully resolved, ensure that an absolute path is returned
12,419 changes: 6,847 additions & 5,572 deletions package-lock.json

Large diffs are not rendered by default.

49 changes: 25 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cross-spawn",
"version": "6.0.5",
"version": "7.0.1",
"description": "Cross platform child_process#spawn and child_process#spawnSync",
"keywords": [
"spawn",
@@ -27,13 +27,17 @@
"lint": "eslint .",
"test": "jest --env node --coverage",
"prerelease": "npm t && npm run lint",
"release": "standard-version",
"precommit": "lint-staged",
"commitmsg": "commitlint -e $GIT_PARAMS"
"release": "standard-version"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-commit": "lint-staged"
}
},
"standard-version": {
"scripts": {
"posttag": "git push --follow-tags origin master && npm publish"
"posttag": "git push --follow-tags origin master"
}
},
"lint-staged": {
@@ -48,29 +52,26 @@
]
},
"dependencies": {
"nice-try": "^1.0.4",
"path-key": "^2.0.1",
"semver": "^5.5.0",
"shebang-command": "^1.2.0",
"which": "^1.2.9"
"path-key": "^3.1.0",
"shebang-command": "^2.0.0",
"which": "^2.0.1"
},
"devDependencies": {
"@commitlint/cli": "^6.0.0",
"@commitlint/config-conventional": "^6.0.2",
"babel-core": "^6.26.0",
"babel-jest": "^22.1.0",
"babel-preset-moxy": "^2.2.1",
"eslint": "^4.3.0",
"eslint-config-moxy": "^5.0.0",
"husky": "^0.14.3",
"jest": "^22.0.0",
"lint-staged": "^7.0.0",
"@commitlint/cli": "^8.1.0",
"@commitlint/config-conventional": "^8.1.0",
"babel-core": "^6.26.3",
"babel-jest": "^24.9.0",
"babel-preset-moxy": "^3.1.0",
"eslint": "^5.16.0",
"eslint-config-moxy": "^7.1.0",
"husky": "^3.0.5",
"jest": "^24.9.0",
"lint-staged": "^9.2.5",
"mkdirp": "^0.5.1",
"regenerator-runtime": "^0.11.1",
"rimraf": "^2.6.2",
"standard-version": "^4.2.0"
"rimraf": "^3.0.0",
"standard-version": "^7.0.0"
},
"engines": {
"node": ">=4.8"
"node": ">= 8"
}
}
5 changes: 4 additions & 1 deletion test/.babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"presets": [["moxy", { "targets": { "node": "4" }}]]
"presets": [
["babel-preset-moxy/lib", {
"lodash": false }
]]
}
3 changes: 1 addition & 2 deletions test/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"root": true,
"extends": [
"eslint-config-moxy/es8",
"eslint-config-moxy/es9",
"eslint-config-moxy/addons/node",
"eslint-config-moxy/addons/object-spread",
"eslint-config-moxy/addons/jest"
]
}
2 changes: 1 addition & 1 deletion test/util/run.js
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@ function run(method, command, args, options) {
}

method = method.replace(/-force-shell$/, '');
options = Object.assign({ forceShell: true }, options);
options = { forceShell: true, ...options };
}

// Run sync version