-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli-wrapper.js
More file actions
31 lines (27 loc) · 786 Bytes
/
cli-wrapper.js
File metadata and controls
31 lines (27 loc) · 786 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
29
30
31
const {stdout, stderr} = require('stdout-stderr')
const cli = require('@ldhertert/harness-cli')
module.exports.runCommand = async function(command, flags) {
stdout.start()
stderr.start()
// stdout.print = true
// stderr.print = true
const args = [ command ]
if (flags) {
Object.keys(flags).forEach(key => {
args.push(`--${key}`)
if (flags[key]) {
args.push(flags[key])
}
})
}
try {
await cli.run(args)
stdout.stop()
stderr.stop()
return stdout.output
} catch(ex) {
stdout.stop()
stderr.stop()
throw new Error(`Error running command: harness ${args.join(' ')}.\Exception: ${ex.message}}\nstderr: ${stderr.output}`)
}
}