summaryrefslogtreecommitdiffstats
path: root/lib/utils/command.js
diff options
context:
space:
mode:
authorSamy Pesse <samypesse@gmail.com>2016-02-11 16:35:41 +0100
committerSamy Pesse <samypesse@gmail.com>2016-02-11 16:35:41 +0100
commit347a536a4e313dece2e12d0ba1ec6654ee729c85 (patch)
tree8308fe7a3b031361bcafaaa94cc76232732e259d /lib/utils/command.js
parent5cf0abaf2b50946420952e9ce36e357ac0d08d54 (diff)
downloadgitbook-347a536a4e313dece2e12d0ba1ec6654ee729c85.zip
gitbook-347a536a4e313dece2e12d0ba1ec6654ee729c85.tar.gz
gitbook-347a536a4e313dece2e12d0ba1ec6654ee729c85.tar.bz2
Add git urls parsing and tests
Diffstat (limited to 'lib/utils/command.js')
-rw-r--r--lib/utils/command.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/utils/command.js b/lib/utils/command.js
new file mode 100644
index 0000000..f395fa1
--- /dev/null
+++ b/lib/utils/command.js
@@ -0,0 +1,19 @@
+var childProcess = require('child_process');
+var Promise = require('./promise');
+
+// On borwser, command execution is not possible
+var isAvailable = childProcess && childProcess.exec;
+
+// Execute a command
+function exec(command, options) {
+ if (!isAvailable) {
+ return Promise.reject(new Error('Command execution is not possible on this platform'));
+ }
+
+ return Promise.nfcall(childProcess.exec, command, options);
+}
+
+module.exports = {
+ isAvailable: isAvailable,
+ exec: exec
+};