UNPKG

576 BJavaScriptView Raw
1const command = require('command-test')
2const path = require('path')
3const cliFile = path.resolve('cli/main.js')
4
5function modify(cmd) {
6 return cmd.replace(/z1/, `${cliFile}`)
7}
8
9/**
10 * Executes a command. Throws if the exit code is not 0.
11 * @param {string} cmd - The command.
12 */
13function works(cmd) {
14 cmd = modify(cmd)
15 return command.works(cmd)
16}
17
18/**
19 * Executes a command. Throws an error if the exit code is 0.
20 * @param {string} cmd - The command.
21 */
22function fails(cmd) {
23 cmd = modify(cmd)
24 return command.fails(cmd)
25}
26
27module.exports = {
28 works,
29 fails
30}