cross-spawn-cb 0.5.10 → 0.5.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  require('./polyfills');
2
2
  module.exports = require('./spawnCallback');
3
+ module.exports.spawn = require('./spawnCallback');
3
4
  module.exports.sync = require('./spawnSyncCallback');
4
5
  module.exports.pathKey = require('./path-key').default;
package/lib/polyfills.js CHANGED
@@ -1,21 +1,10 @@
1
- if (!Object.assign) Object.assign = require('just-extend');
2
- if (!Object.keys) Object.keys = require('object-keys');
1
+ require('core-js/actual/object/assign');
2
+ require('core-js/actual/object/keys');
3
+ require('core-js/actual/array/find');
3
4
 
4
5
  var path = require('path');
5
6
  if (typeof path.delimiter === 'undefined') path.delimiter = process.platform === 'win32' ? ';' : ':';
6
7
 
7
- var cp = require('child_process');
8
- if (!cp.spawnSync) cp.spawnSync = require('./spawn-sync/spawn-sync.js');
9
-
10
- if (!Array.prototype.find) {
11
- Array.prototype.find = function find(fn) {
12
- for (var i = 0; i < this.length; i++) {
13
- if (fn(this[i])) return this[i];
14
- }
15
- return null;
16
- };
17
- }
18
-
19
8
  if (!Buffer.from) {
20
9
  Buffer.from = function from(data) {
21
10
  // eslint-disable-next-line n/no-deprecated-api
@@ -23,3 +12,6 @@ if (!Buffer.from) {
23
12
  };
24
13
  }
25
14
  if (!Buffer.alloc) Buffer.alloc = Buffer.from;
15
+
16
+ var cp = require('child_process');
17
+ if (!cp.spawnSync) cp.spawnSync = require('./spawn-sync/spawn-sync.js');
@@ -7,7 +7,9 @@ var tmpdir = require('os').tmpdir || require('os-shim').tmpdir;
7
7
  var cp = require('child_process');
8
8
  var JSON = require('json-buffer');
9
9
  var sleep = require('thread-sleep-compat');
10
+ var mkdirp = require('mkdirp')
10
11
  var suffix = require('temp-suffix')
12
+ var shortHash = require('short-hash');
11
13
 
12
14
  function unlinkSafe(filename) {
13
15
  try {
@@ -19,10 +21,12 @@ module.exports = function spawnSyncFallback(/*cmd, commandArgs, options*/) {
19
21
  var args = Array.prototype.slice.call(arguments, 0);
20
22
 
21
23
  // location to store arguments
22
- var temp = tmpdir();
23
- var input = path.join(temp, suffix('ss-input'));
24
- var output = path.join(temp, suffix('ss-output'));
24
+ var temp = path.join(tmpdir(), 'spawn-sync', shortHash(process.cwd()));
25
+ var input = path.join(temp , suffix("input"));
26
+ var output = path.join(temp, suffix("output"));
25
27
 
28
+ // store data to a file
29
+ mkdirp.sync(path.dirname(input));
26
30
  fs.writeFileSync(input, JSON.stringify(args));
27
31
  unlinkSafe(output);
28
32
 
@@ -3,22 +3,22 @@
3
3
 
4
4
  require('../polyfills');
5
5
 
6
- var spawn = require('../cross-spawn').spawn;
6
+ var spawn = require('../cross-spawn-3.0.1').spawn;
7
7
  var fs = require('fs');
8
8
  var JSON = require('json-buffer');
9
9
 
10
- var inputFile = process.argv[2];
11
- var outputFile = process.argv[3];
10
+ var input = process.argv[2];
11
+ var output = process.argv[3];
12
12
 
13
- function output(result) {
14
- fs.writeFile(outputFile+'.tmp', JSON.stringify(result), function() {
15
- fs.rename(outputFile+'.tmp', outputFile, function() {
13
+ function writeOutput(result) {
14
+ fs.writeFile(output+'.tmp', JSON.stringify(result), function() {
15
+ fs.rename(output+'.tmp', output, function() {
16
16
  process.exit(0)
17
17
  })
18
18
  });
19
19
  }
20
20
 
21
- fs.readFile(inputFile, 'utf8', function(err, contents) {
21
+ fs.readFile(input, 'utf8', function(err, contents) {
22
22
  if (err) return output({ error: err.message });
23
23
  var args = JSON.parse(contents);
24
24
 
@@ -39,7 +39,7 @@ fs.readFile(inputFile, 'utf8', function(err, contents) {
39
39
  })
40
40
  }
41
41
  child.on('error', function (err) {
42
- output({ pid: child.pid, error: err.message });
42
+ writeOutput({ pid: child.pid, error: err.message });
43
43
  });
44
44
  child.on('close', function (status, signal) {
45
45
  if (stdout) stdout = Buffer.concat(stdout)
@@ -49,7 +49,7 @@ fs.readFile(inputFile, 'utf8', function(err, contents) {
49
49
  stdout = stdout.toString(options.encoding);
50
50
  stderr = stderr.toString(options.encoding);
51
51
  }
52
- output({
52
+ writeOutput({
53
53
  pid: child.pid,
54
54
  output: [null, stdout, stderr],
55
55
  stdout: stdout,
@@ -2,7 +2,8 @@ var assign = require('just-extend');
2
2
  var once = require('once');
3
3
  var nextTick = require('next-tick');
4
4
 
5
- var spawn = require('./cross-spawn').spawn;
5
+ var major = +process.versions.node.split('.')[0];
6
+ var spawn = major < 8 ? require('./cross-spawn-3.0.1').spawn : require('cross-spawn').spawn;
6
7
 
7
8
  module.exports = function spawnCallback(command, args, options, callback) {
8
9
  if (typeof options === 'function') {
@@ -1,11 +1,14 @@
1
1
  var assign = require('just-extend');
2
- var spawnSync = require('./cross-spawn').sync;
2
+
3
+ var major = +process.versions.node.split('.')[0];
4
+ var spawnSync = major < 8 ? require('./cross-spawn-3.0.1').sync : require('cross-spawn').sync;
3
5
 
4
6
  module.exports = function spawnSyncCallback(command, args, options) {
7
+ options = options || {};
5
8
  var syncOptions = assign({}, options || {}, {
6
9
  env: options.env || process.env,
7
10
  stdio: 'pipe',
8
- encoding: 'utf-8',
11
+ encoding: 'utf8',
9
12
  });
10
13
  var result = spawnSync(command, args, syncOptions);
11
14
  if (result.stdout && (options.stdout === 'inherit' || options.stdio === 'inherit')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cross-spawn-cb",
3
- "version": "0.5.10",
3
+ "version": "0.5.13",
4
4
  "description": "Cross spawn with a completion callback",
5
5
  "keywords": [
6
6
  "cross-spawn",
@@ -18,19 +18,21 @@
18
18
  "lint": "eslint .",
19
19
  "prepublishOnly": "dtd \"npm run lint\" \"depcheck\"",
20
20
  "test": "mocha-compat test/spec/**/*.test.js",
21
- "build": "rollup -c config/rollup.pk.config.js && rollup -c config/rollup.cs.config.js"
21
+ "build": "rollup -c config/rollup.cs.config.js"
22
22
  },
23
23
  "files": [
24
24
  "lib"
25
25
  ],
26
26
  "dependencies": {
27
+ "core-js": "^3.23.4",
27
28
  "cross-spawn": "^7.0.3",
28
29
  "json-buffer": "^3.0.1",
29
30
  "just-extend": "^6.0.1",
31
+ "mkdirp": "^0.5.6",
30
32
  "next-tick": "^1.1.0",
31
- "object-keys": "^1.1.1",
32
33
  "once": "^1.4.0",
33
34
  "os-shim": "^0.1.3",
35
+ "short-hash": "^1.0.0",
34
36
  "temp-suffix": "^0.1.0",
35
37
  "thread-sleep-compat": "^0.0.1"
36
38
  },
@@ -39,20 +41,20 @@
39
41
  "@rollup/plugin-babel": "^5.3.1",
40
42
  "@rollup/plugin-commonjs": "^22.0.1",
41
43
  "@rollup/plugin-node-resolve": "^13.3.0",
42
- "@typescript-eslint/parser": "^5.30.0",
44
+ "@typescript-eslint/parser": "^5.30.6",
43
45
  "depcheck": "^1.4.3",
44
46
  "dis-dat": "^0.1.7",
45
- "eslint": "^8.18.0",
47
+ "eslint": "^8.19.0",
46
48
  "eslint-config-prettier": "^8.5.0",
47
49
  "eslint-config-standard": "^17.0.0",
48
50
  "eslint-plugin-import": "^2.26.0",
49
51
  "eslint-plugin-promise": "^6.0.0",
50
52
  "mocha-compat": "^3.5.5",
51
53
  "prettier": "^2.7.1",
52
- "rollup": "^2.75.7",
54
+ "rollup": "^2.76.0",
53
55
  "rollup-plugin-babel": "^4.4.0",
54
56
  "rollup-plugin-commonjs": "^10.1.0",
55
- "rollup-plugin-node-externals": "^4.1.0"
57
+ "rollup-plugin-node-externals": "^4.1.1"
56
58
  },
57
59
  "engines": {
58
60
  "node": ">=0.8"
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2018 Made With MOXY Lda <hello@moxy.studio>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.