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:
authorRuy Adorno <ruyadorno@hotmail.com>2020-11-27 07:15:14 +0300
committerRuy Adorno <ruyadorno@hotmail.com>2020-11-27 19:38:01 +0300
commit9c3413fbcb37e79fc0b3d980e0b5810d7961277c (patch)
tree0632d73fa6309e0e0c7b6d15f8db449e76430c68 /test/lib/link.js
parent523cf69acbda17e13fdbfba068d7231d2d9e8908 (diff)
fix: npm link <pkg> should not save package.json
When running `npm link <pkg>` it should not save the new item to the currrent dependencies of that package.json file. Fixes: #2034 Co-authored-by: Darcy Clarke <darcy@darcyclarke.me> PR-URL: https://github.com/npm/cli/pull/2245 Credit: @ruyadorno Close: #2245 Reviewed-by: @darcyclarke
Diffstat (limited to 'test/lib/link.js')
-rw-r--r--test/lib/link.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/test/lib/link.js b/test/lib/link.js
index 9b7c5df64..a478259f7 100644
--- a/test/lib/link.js
+++ b/test/lib/link.js
@@ -23,6 +23,7 @@ const npm = {
get () {
return false
},
+ find () {},
},
}
const printLinks = async (opts) => {
@@ -196,7 +197,7 @@ t.test('link global linked pkg to local nm when using args', (t) => {
})
t.test('link pkg already in global space', (t) => {
- t.plan(2)
+ t.plan(3)
const testdir = t.testdir({
'global-prefix': {
@@ -224,17 +225,26 @@ t.test('link pkg already in global space', (t) => {
npm.globalDir = resolve(testdir, 'global-prefix', 'lib', 'node_modules')
npm.prefix = resolve(testdir, 'my-project')
+ npm.config.find = () => 'default'
+
const _cwd = process.cwd()
process.chdir(npm.prefix)
reifyOutput = async () => {
reifyOutput = undefined
process.chdir(_cwd)
+ npm.config.find = () => null
const links = await printLinks({
path: npm.prefix,
})
+ t.equal(
+ require(resolve(testdir, 'my-project', 'package.json')).dependencies,
+ undefined,
+ 'should not save to package.json upon linking'
+ )
+
t.matchSnapshot(links, 'should create a local symlink to global pkg')
}