summaryrefslogtreecommitdiffstats
path: root/bin/utils.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-07-12 09:23:15 +0200
committerSamy Pessé <samypesse@gmail.com>2014-07-12 09:23:15 +0200
commitf05b138fd6cbd46ff72ca45bb8f08994df9035b0 (patch)
treefa14cd4828dbe80c91567d72b1d5b3975ebe44f5 /bin/utils.js
parenta9f473260cdbf7944a8d95c4292a93897f9210eb (diff)
downloadgitbook-f05b138fd6cbd46ff72ca45bb8f08994df9035b0.zip
gitbook-f05b138fd6cbd46ff72ca45bb8f08994df9035b0.tar.gz
gitbook-f05b138fd6cbd46ff72ca45bb8f08994df9035b0.tar.bz2
Add base command git:push and git:remote
Diffstat (limited to 'bin/utils.js')
-rw-r--r--bin/utils.js24
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
};