fix(config): global bin directory on Windows

This commit is contained in:
Zoltan Kochan
2020-12-15 03:32:06 +02:00
parent f129b323e4
commit 041537bc3a
5 changed files with 13 additions and 6 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/config": patch
---
Finding global bin directory on Windows.

View File

@@ -43,6 +43,7 @@
},
"devDependencies": {
"@pnpm/config": "link:",
"@pnpm/prepare": "workspace:^0.0.16",
"@types/mz": "^2.7.3",
"@types/ramda": "^0.27.32",
"@types/which": "^1.3.2",

View File

@@ -6,8 +6,8 @@ export default function findBestGlobalPrefixOnWindows (
env: { [key: string]: string | undefined }
) {
if (
(env.LOCALAPPDATA && isSubdir(env.LOCALAPPDATA, defaultNpmGlobalPrefix)) ??
(env.APPDATA && isSubdir(env.APPDATA, defaultNpmGlobalPrefix))
(env.LOCALAPPDATA != null && isSubdir(env.LOCALAPPDATA, defaultNpmGlobalPrefix)) ||
(env.APPDATA != null && isSubdir(env.APPDATA, defaultNpmGlobalPrefix))
) {
return defaultNpmGlobalPrefix
}

View File

@@ -1,6 +1,7 @@
/// <reference path="../../../typings/index.d.ts"/>
import getConfig from '@pnpm/config'
import PnpmError from '@pnpm/error'
import prepare from '@pnpm/prepare'
import './findBestGlobalPrefixOnWindows'
import fs = require('mz/fs')
@@ -198,9 +199,8 @@ test('registries of scoped packages are read', async () => {
})
test('registries in current directory\'s .npmrc have bigger priority then global config settings', async () => {
const tmp = tempy.directory()
prepare()
process.chdir(tmp)
await fs.writeFile('.npmrc', 'registry=https://pnpm.js.org/', 'utf8')
const { config } = await getConfig({
@@ -539,9 +539,8 @@ test('normalize the value of the color flag', async () => {
})
test('read only supported settings from config', async () => {
const tmp = tempy.directory()
prepare()
process.chdir(tmp)
await fs.writeFile('.npmrc', 'store-dir=__store__\nfoo=bar', 'utf8')
const { config } = await getConfig({

2
pnpm-lock.yaml generated
View File

@@ -227,6 +227,7 @@ importers:
which: 2.0.2
devDependencies:
'@pnpm/config': 'link:'
'@pnpm/prepare': 'link:../../privatePackages/prepare'
'@types/mz': 2.7.3
'@types/ramda': 0.27.32
'@types/which': 1.3.2
@@ -237,6 +238,7 @@ importers:
'@pnpm/constants': 'workspace:4.1.0'
'@pnpm/error': 'workspace:1.4.0'
'@pnpm/global-bin-dir': 'workspace:^1.2.5'
'@pnpm/prepare': 'workspace:^0.0.16'
'@pnpm/types': 'workspace:6.3.1'
'@types/mz': ^2.7.3
'@types/ramda': ^0.27.32