Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/commands/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ class Link extends ArboristWorkspaceCmd {
// using any of --save-dev or other types
const save =
Boolean(
this.npm.config.find('save') !== 'default' ||
(this.npm.config.find('save') !== 'default' &&
this.npm.config.get('save')) ||
this.npm.config.get('save-optional') ||
this.npm.config.get('save-peer') ||
this.npm.config.get('save-dev') ||
this.npm.config.get('save-prod')
)

// create a new arborist instance for the local prefix and
// reify all the pending names as symlinks there
const localArb = new Arborist({
Expand Down
34 changes: 34 additions & 0 deletions test/lib/commands/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,40 @@ t.test('link pkg already in global space when prefix is a symlink', async t => {
t.matchSnapshot(await printLinks(), 'should create a local symlink to global pkg')
})

t.test('should not save link to package file', async t => {
const { link, prefix } = await mockLink(t, {
globalPrefixDir: {
node_modules: {
'@myscope': {
linked: t.fixture('symlink', '../../../other/scoped-linked'),
},
},
},
otherDirs: {
'scoped-linked': {
'package.json': JSON.stringify({
name: '@myscope/linked',
version: '1.0.0',
}),
},
},
prefixDir: {
'package.json': JSON.stringify({
name: 'my-project',
version: '1.0.0',
}),
},
config: { save: false },
})

await link.exec(['@myscope/linked'])
t.match(
require(resolve(prefix, 'package.json')).dependencies,
undefined,
'should not save to package.json upon linking'
)
})

t.test('should not prune dependencies when linking packages', async t => {
const { link, prefix } = await mockLink(t, {
globalPrefixDir: {
Expand Down