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
|
const t = require('tap')
const LifecycleCmd = require('../../../lib/utils/lifecycle-cmd.js')
let runArgs = null
const npm = {
commands: {
'run-script': (args, cb) => {
runArgs = args
cb(null, 'called npm.commands.run')
},
},
}
t.test('create a lifecycle command', t => {
t.plan(5)
class TestStage extends LifecycleCmd {
static get name () {
return 'test-stage'
}
}
const cmd = new TestStage(npm)
t.match(cmd.usage, /test-stage/)
cmd.exec(['some', 'args'], (er, result) => {
t.same(runArgs, ['test-stage', 'some', 'args'])
t.strictSame(result, 'called npm.commands.run')
})
cmd.execWorkspaces(['some', 'args'], [], (er, result) => {
t.same(runArgs, ['test-stage', 'some', 'args'])
t.strictSame(result, 'called npm.commands.run')
})
})
|