summaryrefslogtreecommitdiffstats
path: root/lib/utils/command.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-02-25 15:09:57 +0100
committerSamy Pessé <samypesse@gmail.com>2016-02-25 15:09:57 +0100
commit393aed62706745e2abde300844143b5d2a0c9041 (patch)
tree33da1c4e18796ccfe1ad3638228a1fde953e668c /lib/utils/command.js
parentb240d6a8fcbab80ea35da8cee58576f674ea1821 (diff)
downloadgitbook-393aed62706745e2abde300844143b5d2a0c9041.zip
gitbook-393aed62706745e2abde300844143b5d2a0c9041.tar.gz
gitbook-393aed62706745e2abde300844143b5d2a0c9041.tar.bz2
Improve error msg for ebook generation
Diffstat (limited to 'lib/utils/command.js')
-rw-r--r--lib/utils/command.js21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/utils/command.js b/lib/utils/command.js
index 49b0998..c1689cb 100644
--- a/lib/utils/command.js
+++ b/lib/utils/command.js
@@ -11,7 +11,26 @@ function exec(command, options) {
return Promise.reject(new Error('Command execution is not possible on this platform'));
}
- return Promise.nfcall(childProcess.exec, command, options);
+ var d = Promise.defer();
+
+ var child = childProcess.exec(command, options, function(err, stdout, stderr) {
+ if (!err) {
+ d.resolve();
+ }
+
+ err.message = stdout.toString('utf8') + stderr.toString('utf8');
+ d.reject(err);
+ });
+
+ child.stdout.on('data', function (data) {
+ d.notify(data);
+ });
+
+ child.stderr.on('data', function (data) {
+ d.notify(data);
+ });
+
+ return d.promise;
}
// Spawn an executable