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

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2021-02-25 02:54:50 +0300
committerRuy Adorno <ruyadorno@hotmail.com>2021-03-05 00:05:08 +0300
commit4a5dd3a5a200b3f4f7b47168497d8e03dca3a2ca (patch)
treed34a1ea229b719c3cfbdce85899ceaf67b43e7ab /test/lib/rebuild.js
parentb33c760cea7fe2696d35b5530abc1b455980fef1 (diff)
fix(npm) pass npm context everywhere
Instead of files randomly requiring the npm singleton, we pass it where it needs to go so that tests don't need to do so much require mocking everywhere PR-URL: https://github.com/npm/cli/pull/2772 Credit: @wraithgar Close: #2772 Reviewed-by: @ruyadorno
Diffstat (limited to 'test/lib/rebuild.js')
-rw-r--r--test/lib/rebuild.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/test/lib/rebuild.js b/test/lib/rebuild.js
index d9df048d9..ee081c087 100644
--- a/test/lib/rebuild.js
+++ b/test/lib/rebuild.js
@@ -13,14 +13,14 @@ const npm = {
prefix: '',
}
const mocks = {
- '../../lib/npm.js': npm,
'../../lib/utils/output.js': (...msg) => {
result += msg.join('\n')
},
'../../lib/utils/usage.js': () => 'usage instructions',
}
-const rebuild = requireInject('../../lib/rebuild.js', mocks)
+const Rebuild = requireInject('../../lib/rebuild.js', mocks)
+const rebuild = new Rebuild(npm)
t.afterEach(cb => {
npm.prefix = ''
@@ -67,7 +67,7 @@ t.test('no args', t => {
npm.prefix = path
- rebuild([], err => {
+ rebuild.exec([], err => {
if (err)
throw err
@@ -115,7 +115,7 @@ t.test('filter by pkg name', t => {
t.throws(() => fs.statSync(aBinFile))
t.throws(() => fs.statSync(bBinFile))
- rebuild(['b'], err => {
+ rebuild.exec(['b'], err => {
if (err)
throw err
@@ -163,7 +163,7 @@ t.test('filter by pkg@<range>', t => {
const bBinFile = resolve(path, 'node_modules/.bin/b')
const nestedBinFile = resolve(path, 'node_modules/a/node_modules/.bin/b')
- rebuild(['b@2'], err => {
+ rebuild.exec(['b@2'], err => {
if (err)
throw err
@@ -203,7 +203,7 @@ t.test('filter by directory', t => {
t.throws(() => fs.statSync(aBinFile))
t.throws(() => fs.statSync(bBinFile))
- rebuild(['file:node_modules/b'], err => {
+ rebuild.exec(['file:node_modules/b'], err => {
if (err)
throw err
@@ -215,7 +215,7 @@ t.test('filter by directory', t => {
})
t.test('filter must be a semver version/range, or directory', t => {
- rebuild(['git+ssh://github.com/npm/arborist'], err => {
+ rebuild.exec(['git+ssh://github.com/npm/arborist'], err => {
t.match(
err,
/Error: `npm rebuild` only supports SemVer version\/range specifiers/,
@@ -245,7 +245,7 @@ t.test('global prefix', t => {
npm.flatOptions.global = true
npm.globalDir = resolve(globalPath, 'lib', 'node_modules')
- rebuild([], err => {
+ rebuild.exec([], err => {
if (err)
throw err