@pnpm/config
Advanced tools
Comparing version
@@ -44,2 +44,3 @@ "use strict"; | ||
const npmDefaults = npm_conf_1.default.defaults; | ||
const PNPM_GLOBAL = 'pnpm-global'; | ||
async function which(cmd) { | ||
@@ -255,10 +256,18 @@ return new Promise((resolve, reject) => { | ||
if (cliOptions['global']) { | ||
const npmGlobalPrefix = findBestGlobalPrefix_1.default(npmConfig.globalPrefix, process.env); | ||
const knownGlobalBinDirCandidates = []; | ||
let npmGlobalPrefix = findBestGlobalPrefix_1.default(npmConfig.globalPrefix, process.env); | ||
const globalDirName = `${path_1.default.sep}${PNPM_GLOBAL}${path_1.default.sep}`; | ||
if (npmGlobalPrefix.includes(globalDirName)) { | ||
npmGlobalPrefix = npmGlobalPrefix.substring(0, npmGlobalPrefix.indexOf(globalDirName)); | ||
} | ||
else { | ||
const npmGlobalBinDir = process.platform === 'win32' | ||
? npmGlobalPrefix | ||
: path_1.default.resolve(npmGlobalPrefix, 'bin'); | ||
knownGlobalBinDirCandidates.push(npmGlobalBinDir); | ||
} | ||
const globalDirRoot = pnpmConfig['globalDir'] | ||
? pnpmConfig['globalDir'] | ||
: path_1.default.join(firstWithWriteAccess([npmGlobalPrefix, os_1.default.homedir()]), 'pnpm-global'); | ||
: path_1.default.join(firstWithWriteAccess([npmGlobalPrefix, os_1.default.homedir()]), PNPM_GLOBAL); | ||
pnpmConfig.dir = path_1.default.join(globalDirRoot, constants_1.LAYOUT_VERSION.toString()); | ||
const npmGlobalBinDir = process.platform === 'win32' | ||
? npmGlobalPrefix | ||
: path_1.default.resolve(npmGlobalPrefix, 'bin'); | ||
pnpmConfig.bin = cliOptions.dir | ||
@@ -268,3 +277,3 @@ ? (process.platform === 'win32' | ||
: path_1.default.resolve(cliOptions.dir, 'bin')) | ||
: global_bin_dir_1.default([npmGlobalBinDir], { shouldAllowWrite: opts.globalDirShouldAllowWrite === true }); | ||
: global_bin_dir_1.default(knownGlobalBinDirCandidates, { shouldAllowWrite: opts.globalDirShouldAllowWrite === true }); | ||
pnpmConfig.save = true; | ||
@@ -271,0 +280,0 @@ pnpmConfig.allowNew = true; |
100
package.json
{ | ||
"name": "@pnpm/config", | ||
"version": "12.4.1", | ||
"description": "Gets configuration options for pnpm", | ||
"main": "lib/index.js", | ||
"typings": "lib/index.d.ts", | ||
"files": [ | ||
"lib", | ||
"!*.map" | ||
], | ||
"repository": "https://github.com/pnpm/pnpm/blob/master/packages/config", | ||
"keywords": [ | ||
"pnpm", | ||
"config" | ||
], | ||
"engines": { | ||
"node": ">=12.17" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/pnpm/pnpm/issues" | ||
}, | ||
"homepage": "https://github.com/pnpm/pnpm/blob/master/packages/config#readme", | ||
"dependencies": { | ||
"@pnpm/constants": "5.0.0", | ||
"@pnpm/error": "2.0.0", | ||
"@pnpm/global-bin-dir": "2.0.0", | ||
"@pnpm/types": "7.3.0", | ||
"@zkochan/npm-conf": "2.0.2", | ||
"camelcase": "^6.2.0", | ||
"can-write-to-dir": "^1.1.1", | ||
"is-subdir": "^1.1.1", | ||
"ramda": "^0.27.1", | ||
"realpath-missing": "^1.1.0", | ||
"which": "^2.0.2" | ||
}, | ||
"devDependencies": { | ||
"@pnpm/prepare": "0.0.25", | ||
"@types/ramda": "0.27.39", | ||
"@types/which": "^2.0.0", | ||
"symlink-dir": "^5.0.0" | ||
}, | ||
"funding": "https://opencollective.com/pnpm", | ||
"scripts": { | ||
"lint": "eslint -c ../../eslint.json src/**/*.ts test/**/*.ts", | ||
"test-with-preview": "ts-node test", | ||
"_test": "jest", | ||
"test": "pnpm run compile && pnpm run _test", | ||
"compile": "rimraf lib tsconfig.tsbuildinfo && tsc --build && pnpm run lint -- --fix" | ||
} | ||
} | ||
"name": "@pnpm/config", | ||
"version": "12.4.2", | ||
"description": "Gets configuration options for pnpm", | ||
"main": "lib/index.js", | ||
"typings": "lib/index.d.ts", | ||
"files": [ | ||
"lib", | ||
"!*.map" | ||
], | ||
"repository": "https://github.com/pnpm/pnpm/blob/master/packages/config", | ||
"keywords": [ | ||
"pnpm", | ||
"config" | ||
], | ||
"engines": { | ||
"node": ">=12.17" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/pnpm/pnpm/issues" | ||
}, | ||
"homepage": "https://github.com/pnpm/pnpm/blob/master/packages/config#readme", | ||
"dependencies": { | ||
"@pnpm/constants": "5.0.0", | ||
"@pnpm/error": "2.0.0", | ||
"@pnpm/global-bin-dir": "2.0.0", | ||
"@pnpm/types": "7.3.0", | ||
"@zkochan/npm-conf": "2.0.2", | ||
"camelcase": "^6.2.0", | ||
"can-write-to-dir": "^1.1.1", | ||
"is-subdir": "^1.1.1", | ||
"ramda": "^0.27.1", | ||
"realpath-missing": "^1.1.0", | ||
"which": "^2.0.2" | ||
}, | ||
"devDependencies": { | ||
"@pnpm/prepare": "0.0.25", | ||
"@types/ramda": "0.27.39", | ||
"@types/which": "^2.0.0", | ||
"symlink-dir": "^5.0.0" | ||
}, | ||
"funding": "https://opencollective.com/pnpm", | ||
"scripts": { | ||
"lint": "eslint -c ../../eslint.json src/**/*.ts test/**/*.ts", | ||
"test-with-preview": "ts-node test", | ||
"_test": "jest", | ||
"test": "pnpm run compile && pnpm run _test", | ||
"compile": "rimraf lib tsconfig.tsbuildinfo && tsc --build && pnpm run lint -- --fix" | ||
} | ||
} |
51575
21.29%21
31.25%726
1.26%