cross-spawn-cb 0.5.14 → 0.5.15

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.
@@ -28,16 +28,19 @@ module.exports = function spawnCallback(command, args, options, callback) {
28
28
  });
29
29
  cp.on('close', function (status, signal) {
30
30
  nextTick(function closeNextTick() {
31
- // format results
31
+ // format results - buffer
32
32
  if (stdout) stdout = Buffer.concat(stdout);
33
33
  if (stderr) stderr = Buffer.concat(stderr);
34
+
35
+ // format results - string
36
+ var encoding = options.encoding === 'buffer' ? 'utf8' : options.encoding || 'utf8';
34
37
  if ((options.encoding && options.encoding !== 'buffer') || options.stdio === 'string') {
35
- stdout = stdout.toString(options.encoding);
36
- stderr = stderr.toString(options.encoding);
38
+ stdout = stdout.toString(encoding);
39
+ stderr = stderr.toString(encoding);
37
40
  } else if (options.stdout === 'string') {
38
- stdout = stdout.toString(options.encoding);
41
+ stdout = stdout.toString(encoding);
39
42
  } else if (options.stderr === 'string') {
40
- stderr = stderr.toString(options.encoding);
43
+ stderr = stderr.toString(encoding);
41
44
  }
42
45
 
43
46
  // process errors
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cross-spawn-cb",
3
- "version": "0.5.14",
3
+ "version": "0.5.15",
4
4
  "description": "Cross spawn with a completion callback",
5
5
  "keywords": [
6
6
  "cross-spawn",