forked from 418sec/hexo-admin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.js
26 lines (22 loc) · 665 Bytes
/
deploy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var spawn = require('child_process').spawn
function once(fn) {
var called = false
return function () {
if (!called) fn.apply(this, arguments)
called = true
}
}
module.exports = function (command, message, done) {
done = once(done);
var proc = spawn(command, [message], {detached: true});
var stdout = '';
var stderr = '';
proc.stdout.on('data', function(data){stdout += data.toString()})
proc.stderr.on('data', function(data){stderr += data.toString()})
proc.on('error', function(err) {
done(err, {stdout: stdout, stderr: stderr});
});
proc.on('close', function () {
done(null, {stdout: stdout, stderr: stderr});
});
}