@vbarbarosh/node-helpers 2.6.0 → 3.0.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/package.json +1 -1
- package/src/progress.js +2 -0
- package/src/shell.js +9 -1
- package/src/shell_spawn.js +1 -1
- package/src/shell_stdall.js +12 -0
package/package.json
CHANGED
package/src/progress.js
CHANGED
package/src/shell.js
CHANGED
|
@@ -4,7 +4,15 @@ function shell(args, options)
|
|
|
4
4
|
{
|
|
5
5
|
return new Promise(function (resolve, reject) {
|
|
6
6
|
child_process.execFile(args[0], args.slice(1), options, function (error, stdout, stderr) {
|
|
7
|
-
|
|
7
|
+
if (error) {
|
|
8
|
+
reject(error);
|
|
9
|
+
}
|
|
10
|
+
else if (stderr) {
|
|
11
|
+
reject(new Error(`Process terminated with the following stderr:\n\n${stderr}`));
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
resolve(stdout);
|
|
15
|
+
}
|
|
8
16
|
});
|
|
9
17
|
});
|
|
10
18
|
}
|
package/src/shell_spawn.js
CHANGED
|
@@ -2,8 +2,8 @@ const child_process = require('child_process');
|
|
|
2
2
|
|
|
3
3
|
function shell_spawn(args, options)
|
|
4
4
|
{
|
|
5
|
-
const proc = child_process.spawn(args[0], args.slice(1), options);
|
|
6
5
|
let promise;
|
|
6
|
+
const proc = child_process.spawn(args[0], args.slice(1), options);
|
|
7
7
|
proc.promise = function () {
|
|
8
8
|
let is_pending = true;
|
|
9
9
|
return promise = promise || new Promise(function (resolve, reject) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const child_process = require('child_process');
|
|
2
|
+
|
|
3
|
+
function shell_stdall(args, options)
|
|
4
|
+
{
|
|
5
|
+
return new Promise(function (resolve, reject) {
|
|
6
|
+
child_process.execFile(args[0], args.slice(1), options, function (error, stdout, stderr) {
|
|
7
|
+
error ? reject(error) : resolve({stdout, stderr});
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = shell_stdall;
|