cross-spawn-cb 0.5.10 → 0.5.11

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.
@@ -7,6 +7,7 @@ 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')
11
12
 
12
13
  function unlinkSafe(filename) {
@@ -19,10 +20,12 @@ module.exports = function spawnSyncFallback(/*cmd, commandArgs, options*/) {
19
20
  var args = Array.prototype.slice.call(arguments, 0);
20
21
 
21
22
  // 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'));
23
+ var temp = path.join(tmpdir(), 'ss');
24
+ var input = path.join(temp , suffix("input"));
25
+ var output = path.join(temp, suffix("output"));
25
26
 
27
+ // store data to a file
28
+ mkdirp.sync(path.dirname(input));
26
29
  fs.writeFileSync(input, JSON.stringify(args));
27
30
  unlinkSafe(output);
28
31
 
@@ -7,18 +7,18 @@ var spawn = require('../cross-spawn').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,
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.11",
4
4
  "description": "Cross spawn with a completion callback",
5
5
  "keywords": [
6
6
  "cross-spawn",
@@ -27,6 +27,7 @@
27
27
  "cross-spawn": "^7.0.3",
28
28
  "json-buffer": "^3.0.1",
29
29
  "just-extend": "^6.0.1",
30
+ "mkdirp": "^0.5.6",
30
31
  "next-tick": "^1.1.0",
31
32
  "object-keys": "^1.1.1",
32
33
  "once": "^1.4.0",