• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// This test ensures that a few commands do the same
2// thing when the cwd is where package.json is, and when
3// the package.json is one level up.
4
5var test = require('tap').test
6var common = require('../common-tap.js')
7var path = require('path')
8var root = path.resolve(__dirname, '../..')
9var lib = path.resolve(root, 'lib')
10var commands = ['run', 'version']
11
12commands.forEach(function (cmd) {
13  // Should get the same stdout and stderr each time
14  var stdout, stderr
15
16  test(cmd + ' in root', function (t) {
17    common.npm([cmd], {cwd: root}, function (er, code, so, se) {
18      if (er) throw er
19      t.notOk(code, 'npm ' + cmd + ' exited with code 0')
20      stdout = so
21      stderr = se
22      t.end()
23    })
24  })
25
26  test(cmd + ' in lib', function (t) {
27    common.npm([cmd], {cwd: lib}, function (er, code, so, se) {
28      if (er) throw er
29      t.notOk(code, 'npm ' + cmd + ' exited with code 0')
30      t.equal(so, stdout)
31      t.equal(se, stderr)
32      t.end()
33    })
34  })
35})
36