-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathvici.script.exec.js
More file actions
28 lines (24 loc) · 851 Bytes
/
vici.script.exec.js
File metadata and controls
28 lines (24 loc) · 851 Bytes
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
26
27
28
var child_process = require('child_process')
var spawn = child_process.spawn
module.exports = function (config) {
console.log('=======================================')
console.log('Executing ' + config.action.name)
console.log('=======================================')
var actionSpawn = spawn(config.action.script,
[
JSON.stringify(config.payload || {}),
JSON.stringify(config.query || {}),
JSON.stringify(config.params || {})
])
actionSpawn.stdout.on('data', function (data) {
console.log(data.toString())
})
actionSpawn.stderr.on('data', function (data) {
console.error(data.toString())
})
actionSpawn.on('close', function (code) {
console.log(config.action.name + ': Exited with Code ' + code)
console.log('=======================================')
config.callback(code)
})
}