Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: npm link does not respect --no-save #6910

Merged
merged 10 commits into from
Oct 31, 2023
5 changes: 3 additions & 2 deletions lib/commands/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
: this.linkPkg()
}

async linkInstall (args) {

Check failure on line 66 in lib/commands/link.js

View workflow job for this annotation

GitHub Actions / Lint

Block must not be padded by blank lines

// load current packages from the global space,
// and then add symlinks installs locally
const globalTop = resolve(this.npm.globalDir, '..')
Expand Down Expand Up @@ -109,13 +110,13 @@
// using any of --save-dev or other types
const save =
Boolean(
this.npm.config.find('save') !== 'default' ||
(this.npm.config.find('save') !== 'default' &&

Check failure on line 113 in lib/commands/link.js

View workflow job for this annotation

GitHub Actions / Lint

Trailing spaces not allowed
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
9 changes: 4 additions & 5 deletions test/lib/commands/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,14 +315,13 @@ t.test('link pkg already in global space', async t => {
})

// XXX: how to convert this to a config that gets passed in?
npm.config.find = () => 'default'
npm.config.find = () => '--save'
Santoshraj2 marked this conversation as resolved.
Show resolved Hide resolved

await link.exec(['@myscope/linked'])

t.equal(
t.match(
require(resolve(prefix, 'package.json')).dependencies,
undefined,
'should not save to package.json upon linking'
{ '@myscope/linked': 'file:../other/scoped-linked' },
'should save to package.json upon linking'
)

t.matchSnapshot(await printLinks(), 'should create a local symlink to global pkg')
Expand Down
Loading