Skip to content

Commit 16feb53

Browse files
Siilwynsatazor
authored andcommittedAug 20, 2019
refactor: drop support for versions below Node.js 8 (#125)
BREAKING CHANGE: drop support for Node.js < 8
1 parent 48bee1d commit 16feb53

7 files changed

+16
-75
lines changed
 

‎.travis.yml

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
language: node_js
22
node_js:
3-
- '4.7'
4-
- '4.8'
5-
- '5.6'
6-
- '5.7'
7-
- '6'
8-
- 'lts/*'
9-
# nodejs 11.11.X was failing with this https://travis-ci.org/moxystudio/node-proper-lockfile/jobs/503161746#L469
10-
# - 'node'
3+
- 8
4+
- 9
5+
- 10
6+
- 12
117
after_success:
12-
- "npm i codecov"
13-
- "node_modules/.bin/codecov"
8+
- 'npm i codecov'
9+
- 'node_modules/.bin/codecov'

‎README.md

+3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ A cross platform solution to node's spawn and spawnSync.
2121

2222
## Installation
2323

24+
Node.js version 8 and up:
2425
`$ npm install cross-spawn`
2526

27+
Node.js version 7 and under:
28+
`$ npm install cross-spawn@6`
2629

2730
## Why
2831

‎appveyor.yml

+2-11
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,12 @@
44
init:
55
- git config --global core.autocrlf input
66

7-
# If we are running on Node <6, we must install npm v3 otherwise
8-
# there will be intermitent errors when running `npm install`
97
environment:
108
matrix:
11-
- nodejs_version: 4.7
12-
npm_version: ^3.0.0
13-
- nodejs_version: 4.8
14-
npm_version: ^3.0.0
15-
- nodejs_version: 5.6
16-
npm_version: ^3.0.0
17-
- nodejs_version: 5.7
18-
npm_version: ^3.0.0
19-
- nodejs_version: 6
209
- nodejs_version: 8
2110
- nodejs_version: 9
11+
- nodejs_version: 10
12+
- nodejs_version: 12
2213

2314
install:
2415
- ps: Install-Product node $env:nodejs_version

‎lib/parse.js

+1-35
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
'use strict';
22

33
const path = require('path');
4-
const niceTry = require('nice-try');
54
const resolveCommand = require('./util/resolveCommand');
65
const escape = require('./util/escape');
76
const readShebang = require('./util/readShebang');
8-
const semver = require('semver');
97

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

14-
// `options.shell` is supported in Node ^4.8.0, ^5.7.0 and >= 6.0.0
15-
const supportsShellOption = niceTry(() => semver.satisfies(process.version, '^4.8.0 || ^5.7.0 || >= 6.0.0', true)) || false;
16-
1712
function detectShebang(parsed) {
1813
parsed.file = resolveCommand(parsed);
1914

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

70-
function parseShell(parsed) {
71-
// If node supports the shell option, there's no need to mimic its behavior
72-
if (supportsShellOption) {
73-
return parsed;
74-
}
75-
76-
// Mimic node shell option
77-
// See https://github.com/nodejs/node/blob/b9f6a2dc059a1062776133f3d4fd848c4da7d150/lib/child_process.js#L335
78-
const shellCommand = [parsed.command].concat(parsed.args).join(' ');
79-
80-
if (isWin) {
81-
parsed.command = typeof parsed.options.shell === 'string' ? parsed.options.shell : process.env.comspec || 'cmd.exe';
82-
parsed.args = ['/d', '/s', '/c', `"${shellCommand}"`];
83-
parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped
84-
} else {
85-
if (typeof parsed.options.shell === 'string') {
86-
parsed.command = parsed.options.shell;
87-
} else if (process.platform === 'android') {
88-
parsed.command = '/system/bin/sh';
89-
} else {
90-
parsed.command = '/bin/sh';
91-
}
92-
93-
parsed.args = ['-c', shellCommand];
94-
}
95-
96-
return parsed;
97-
}
98-
9965
function parse(command, args, options) {
10066
// Normalize arguments, similar to nodejs
10167
if (args && !Array.isArray(args)) {
@@ -119,7 +85,7 @@ function parse(command, args, options) {
11985
};
12086

12187
// Delegate further parsing to shell or non-shell
122-
return options.shell ? parseShell(parsed) : parseNonShell(parsed);
88+
return options.shell ? parsed : parseNonShell(parsed);
12389
}
12490

12591
module.exports = parse;

‎lib/util/readShebang.js

+1-10
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,7 @@ const shebangCommand = require('shebang-command');
66
function readShebang(command) {
77
// Read the first 150 bytes from the file
88
const size = 150;
9-
let buffer;
10-
11-
if (Buffer.alloc) {
12-
// Node.js v4.5+ / v5.10+
13-
buffer = Buffer.alloc(size);
14-
} else {
15-
// Old Node.js API
16-
buffer = new Buffer(size);
17-
buffer.fill(0); // zero-fill
18-
}
9+
const buffer = Buffer.alloc(size);
1910

2011
let fd;
2112

‎package-lock.json

+2-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@
4848
]
4949
},
5050
"dependencies": {
51-
"nice-try": "^1.0.4",
5251
"path-key": "^2.0.1",
53-
"semver": "^5.5.0",
5452
"shebang-command": "^1.2.0",
5553
"which": "^1.2.9"
5654
},
@@ -71,6 +69,6 @@
7169
"standard-version": "^4.2.0"
7270
},
7371
"engines": {
74-
"node": ">=4.8"
72+
"node": ">= 8"
7573
}
7674
}

0 commit comments

Comments
 (0)
Please sign in to comment.