cross-spawn-cb 0.5.15 → 0.6.0
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/spawnCallback.js +4 -9
- package/package.json +1 -1
package/lib/spawnCallback.js
CHANGED
|
@@ -33,21 +33,16 @@ module.exports = function spawnCallback(command, args, options, callback) {
|
|
|
33
33
|
if (stderr) stderr = Buffer.concat(stderr);
|
|
34
34
|
|
|
35
35
|
// format results - string
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
stderr = stderr.toString(encoding);
|
|
40
|
-
} else if (options.stdout === 'string') {
|
|
41
|
-
stdout = stdout.toString(encoding);
|
|
42
|
-
} else if (options.stderr === 'string') {
|
|
43
|
-
stderr = stderr.toString(encoding);
|
|
36
|
+
if ((options.encoding && options.encoding !== 'buffer')) {
|
|
37
|
+
stdout = stdout.toString(options.encoding);
|
|
38
|
+
stderr = stderr.toString(options.encoding);
|
|
44
39
|
}
|
|
45
40
|
|
|
46
41
|
// process errors
|
|
47
42
|
var err = status !== 0 ? new Error('Non-zero exit code: ' + status) : null;
|
|
48
43
|
if (stderr && stderr.length) {
|
|
49
44
|
err = err || new Error('stderr has content');
|
|
50
|
-
err.stderr = stderr;
|
|
45
|
+
err.stderr = Buffer.isBuffer(stderr) ? stderr.toString('utf8') : stderr;
|
|
51
46
|
}
|
|
52
47
|
if (err) return callback(err);
|
|
53
48
|
|