UNPKG

441 BJavaScriptView Raw
1'use strict'
2
3const spawnSync = require('cross-spawn').sync
4const logger = require('./logger')
5
6/* istanbul ignore next */
7module.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}