Skip to content

Commit

Permalink
[npm#5280] Allow --no-save to prevent other save flags from overwriti…
Browse files Browse the repository at this point in the history
…ng save
  • Loading branch information
ficocelliguy committed Mar 5, 2024
1 parent f7e4d7d commit 7db7c47
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion workspaces/config/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ class Config {

// Only set 'save' to true if a saveType has been specified
// and if 'save' is false due to non-default config
if (!this.isDefault('save') && this.#flatOptions.saveType) {
if (!this.isDefault('save') && this.#flatOptions.saveType
&& !this.argv?.includes('--no-save')) {
this.#flatOptions.save = true
}
this.#flatOptions.nodeBin = this.execPath
Expand Down
6 changes: 3 additions & 3 deletions workspaces/config/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -944,9 +944,9 @@ t.test('manages the save flag when flat is retrieved', t => {
const c = await buildConfig(['--no-save'], true)
t.equal(c.flat.save, false)
})
t.test('overwrites save if --no-save is present and also a save flag', async t => {
const c = await buildConfig(['--save-prod', '--no-save'], false)
t.equal(c.flat.save, true)
t.test('oes not overwrite save --no-save is present in addition to save flag', async t => {
const c = await buildConfig(['--save-prod', '--no-save'], true)
t.equal(c.flat.save, false)
})
t.end()
})
Expand Down

0 comments on commit 7db7c47

Please sign in to comment.