1 |
|
2 |
|
3 | const spawnSync = require('cross-spawn').sync
|
4 | const logger = require('./logger')
|
5 |
|
6 | /* istanbul ignore next */
|
7 | module.exports = (cmd, args, opts) => {
|
8 | opts = opts || {}
|
9 |
|
10 | const errMessage = opts.errorMessage
|
11 | const command = spawnSync(cmd, args || [], opts)
|
12 |
|
13 | if (command.status === 1) {
|
14 | if (command.stderr) {
|
15 | logger.fatal(errMessage || command.stderr.toString())
|
16 | }
|
17 | process.exit(1)
|
18 | }
|
19 |
|
20 | return command
|
21 | }
|