diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-07-11 17:42:16 -0700 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-07-11 17:42:16 -0700 |
commit | 3842e5bf4a42f75aed9ed413047a503920226589 (patch) | |
tree | 46a6624f18381a8abb682cfd0b9941a2bc6032cf /bin/utils.js | |
parent | 1b87cec893806928a9f26bfe5e04102645dad0e5 (diff) | |
parent | f05b138fd6cbd46ff72ca45bb8f08994df9035b0 (diff) | |
download | gitbook-3842e5bf4a42f75aed9ed413047a503920226589.zip gitbook-3842e5bf4a42f75aed9ed413047a503920226589.tar.gz gitbook-3842e5bf4a42f75aed9ed413047a503920226589.tar.bz2 |
Merge pull request #358 from GitbookIO/featureplatform
Add base command git:push and git:remote
Diffstat (limited to 'bin/utils.js')
-rw-r--r-- | bin/utils.js | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/bin/utils.js b/bin/utils.js index 74a09b5..821112e 100644 --- a/bin/utils.js +++ b/bin/utils.js @@ -1,6 +1,7 @@ var Q = require('q'); var _ = require('lodash'); +var exec = require('child_process').exec; var http = require('http'); var send = require('send'); @@ -36,9 +37,30 @@ function logError(err) { return Q.reject(err); }; +function runGitCommand(command, args) { + var d = Q.defer(), child; + args = ["git", command].concat(args).join(" "); + + child = exec(args, function (error, stdout, stderr) { + if (error !== null) { + error.stdout = stdout; + error.stderr = stderr; + d.reject(error); + } else { + d.resolve({ + stdout: stdout, + stderr: stderr + }) + } + }); + + return d.promise; +}; + // Exports module.exports = { watch: watch, - logError: logError + logError: logError, + gitCmd: runGitCommand }; |