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

Release/v7.7.1 #2938

Merged
merged 5 commits into from Mar 24, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -765,3 +765,4 @@ Jan Sepke <625043+jansepke@users.noreply.github.com>
Augusto Moura <augusto.borgesm@gmail.com>
Eric Chow <eric.zjp.chow@gmail.com>
kbayrhammer <klaus.bayrhammer@redbull.com>
James Chen-Smith <jameschensmith@gmail.com>
13 changes: 13 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,16 @@
## v7.7.1 (2021-03-24)

### BUG FIXES

* [`543b0e39b`](https://github.com/npm/cli/commit/543b0e39bcb94fc408804b01ca9c0d7b960b2681)
[#2930](https://github.com/npm/cli/issues/2930)
fix(uninstall): use correct local prefix
([@jameschensmith](https://github.com/jameschensmith))
* [`dce4960ef`](https://github.com/npm/cli/commit/dce4960ef6d52af128affe7755b2ca72de913b6c)
[#2932](https://github.com/npm/cli/issues/2932)
fix(config): flatten savePrefix properly
([@wraithgar](https://github.com/wraithgar))

## v7.7.0 (2021-03-23)

### FEATURES
Expand Down
5 changes: 3 additions & 2 deletions lib/uninstall.js
Expand Up @@ -38,8 +38,9 @@ class Uninstall extends BaseCommand {
async uninstall (args) {
// the /path/to/node_modules/..
const global = this.npm.config.get('global')
const prefix = this.npm.config.get('prefix')
const path = global ? resolve(this.npm.globalDir, '..') : prefix
const path = global
? resolve(this.npm.globalDir, '..')
: this.npm.localPrefix

if (!args.length) {
if (!global)
Expand Down
4 changes: 3 additions & 1 deletion lib/utils/config/definitions.js
Expand Up @@ -1581,7 +1581,9 @@ define('save-prefix', {
\`npm config set save-prefix='~'\` it would be set to \`~1.2.3\` which
only allows patch upgrades.
`,
flatten,
flatten (key, obj, flatOptions) {
flatOptions.savePrefix = obj['save-exact'] ? '' : obj['save-prefix']
},
})

define('save-prod', {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,5 +1,5 @@
{
"version": "7.7.0",
"version": "7.7.1",
"name": "npm",
"description": "a package manager for JavaScript",
"keywords": [
Expand Down
6 changes: 3 additions & 3 deletions test/lib/uninstall.js
Expand Up @@ -22,6 +22,7 @@ const uninstall = new Uninstall(npm)
t.afterEach(cb => {
npm.globalDir = ''
npm.prefix = ''
npm.localPrefix = ''
npm.flatOptions.global = false
npm.flatOptions.prefix = ''
cb()
Expand Down Expand Up @@ -85,7 +86,7 @@ t.test('remove single installed lib', t => {
const b = resolve(path, 'node_modules/b')
t.ok(() => fs.statSync(b))

npm.config.set('prefix', path)
npm.localPrefix = path

uninstall.exec(['b'], err => {
if (err)
Expand Down Expand Up @@ -148,7 +149,7 @@ t.test('remove multiple installed libs', t => {
t.ok(() => fs.statSync(a))
t.ok(() => fs.statSync(b))

npm.config.set('prefix', path)
npm.localPrefix = path

uninstall.exec(['b'], err => {
if (err)
Expand Down Expand Up @@ -196,7 +197,6 @@ t.test('no args global', t => {
npm.localPrefix = resolve(path, 'projects', 'a')
npm.globalDir = resolve(path, 'lib', 'node_modules')
npm.config.set('global', true)
npm.config.set('prefix', path)

const a = resolve(path, 'lib/node_modules/a')
t.ok(() => fs.statSync(a))
Expand Down
15 changes: 15 additions & 0 deletions test/lib/utils/config/definitions.js
Expand Up @@ -695,3 +695,18 @@ t.test('user-agent', t => {
t.equal(flat.userAgent, expectCI)
t.end()
})

t.test('save-prefix', t => {
const obj = {
'save-exact': true,
'save-prefix': '~1.2.3',
}
const flat = {}
definitions['save-prefix']
.flatten('save-prefix', { ...obj, 'save-exact': true }, flat)
t.strictSame(flat, { savePrefix: '' })
definitions['save-prefix']
.flatten('save-prefix', { ...obj, 'save-exact': false }, flat)
t.strictSame(flat, { savePrefix: '~1.2.3' })
t.end()
})
6 changes: 6 additions & 0 deletions test/lib/utils/config/flatten.js
Expand Up @@ -6,6 +6,8 @@ delete process.env.NODE
process.execPath = '/path/to/node'

const obj = {
'save-exact': true,
'save-prefix': 'ignored',
'save-dev': true,
'@foobar:registry': 'https://foo.bar.com/',
'//foo.bar.com:_authToken': 'foobarbazquuxasdf',
Expand All @@ -15,6 +17,8 @@ const obj = {
const flat = flatten(obj)
t.strictSame(flat, {
saveType: 'dev',
saveExact: true,
savePrefix: '',
'@foobar:registry': 'https://foo.bar.com/',
'//foo.bar.com:_authToken': 'foobarbazquuxasdf',
npmBin: '/path/to/npm',
Expand All @@ -26,6 +30,8 @@ t.strictSame(flat, {
process.env.NODE = '/usr/local/bin/node.exe'
flatten({ 'save-dev': false }, flat)
t.strictSame(flat, {
saveExact: true,
savePrefix: '',
'@foobar:registry': 'https://foo.bar.com/',
'//foo.bar.com:_authToken': 'foobarbazquuxasdf',
npmBin: '/path/to/npm',
Expand Down