Welcome to mirror list, hosted at ThFree Co, Russian Federation.

lifecycle-cmd.js « utils « lib « test - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3e3a7da43443e89a5940032f480cf72f910473a3 (plain)
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
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 => {
  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')
    t.end()
  })
})