Skip to content

Commit 543b0e3

Browse files
James Chen-Smithruyadorno
authored andcommitted
fix(uninstall): use correct local prefix
Corrects non-global prefix path by using this.npm.localPrefix. A location already used throughout the repository. Later, this will be taken from the unified config library. Signed-off-by: James Chen-Smith <[email protected]> PR-URL: #2930 Credit: @jameschensmith Close: #2930 Reviewed-by: @ruyadorno
1 parent 581b60b commit 543b0e3

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lib/uninstall.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ class Uninstall extends BaseCommand {
3838
async uninstall (args) {
3939
// the /path/to/node_modules/..
4040
const global = this.npm.config.get('global')
41-
const prefix = this.npm.config.get('prefix')
42-
const path = global ? resolve(this.npm.globalDir, '..') : prefix
41+
const path = global
42+
? resolve(this.npm.globalDir, '..')
43+
: this.npm.localPrefix
4344

4445
if (!args.length) {
4546
if (!global)

test/lib/uninstall.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const uninstall = new Uninstall(npm)
2222
t.afterEach(cb => {
2323
npm.globalDir = ''
2424
npm.prefix = ''
25+
npm.localPrefix = ''
2526
npm.flatOptions.global = false
2627
npm.flatOptions.prefix = ''
2728
cb()
@@ -85,7 +86,7 @@ t.test('remove single installed lib', t => {
8586
const b = resolve(path, 'node_modules/b')
8687
t.ok(() => fs.statSync(b))
8788

88-
npm.config.set('prefix', path)
89+
npm.localPrefix = path
8990

9091
uninstall.exec(['b'], err => {
9192
if (err)
@@ -148,7 +149,7 @@ t.test('remove multiple installed libs', t => {
148149
t.ok(() => fs.statSync(a))
149150
t.ok(() => fs.statSync(b))
150151

151-
npm.config.set('prefix', path)
152+
npm.localPrefix = path
152153

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

201201
const a = resolve(path, 'lib/node_modules/a')
202202
t.ok(() => fs.statSync(a))

0 commit comments

Comments
 (0)