1 | const command = require('command-test')
|
2 | const path = require('path')
|
3 | const cliFile = path.resolve('cli/main.js')
|
4 |
|
5 | function 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 | */
|
13 | function 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 | */
|
22 | function fails(cmd) {
|
23 | cmd = modify(cmd)
|
24 | return command.fails(cmd)
|
25 | }
|
26 |
|
27 | module.exports = {
|
28 | works,
|
29 | fails
|
30 | }
|