@pnpm/global-bin-dir
Advanced tools
Comparing version 1.0.1 to 1.1.0
# @pnpm/global-bin-dir | ||
## 1.1.0 | ||
### Minor Changes | ||
- 915828b46: `globalBinDir()` may accept an array of suitable executable directories. | ||
If one of these directories is in PATH and has bigger priority than the | ||
npm/pnpm/nodejs directories, then that directory will be used. | ||
## 1.0.1 | ||
@@ -4,0 +12,0 @@ |
@@ -1,1 +0,1 @@ | ||
export default function (): string; | ||
export default function (knownCandidates?: string[]): string; |
@@ -7,3 +7,3 @@ "use strict"; | ||
const PATH = require("path-name"); | ||
function default_1() { | ||
function default_1(knownCandidates = []) { | ||
var _a, _b; | ||
@@ -14,7 +14,11 @@ if (!process.env[PATH]) { | ||
const dirs = (_b = (_a = process.env[PATH]) === null || _a === void 0 ? void 0 : _a.split(path.delimiter)) !== null && _b !== void 0 ? _b : []; | ||
return pickBestGlobalBinDir(dirs); | ||
const nodeBinDir = path.dirname(process.execPath); | ||
return pickBestGlobalBinDir(dirs, [ | ||
...knownCandidates, | ||
nodeBinDir, | ||
]); | ||
} | ||
exports.default = default_1; | ||
function pickBestGlobalBinDir(dirs) { | ||
const nodeBinDir = path.dirname(process.execPath); | ||
const areDirsEqual = (dir1, dir2) => path.relative(dir1, dir2) === ''; | ||
function pickBestGlobalBinDir(dirs, knownCandidates) { | ||
const noWriteAccessDirs = []; | ||
@@ -27,3 +31,3 @@ for (const dir of dirs) { | ||
isUnderDir('pnpm', lowCaseDir) || | ||
path.relative(nodeBinDir, dir) === '') { | ||
knownCandidates.some((candidate) => areDirsEqual(candidate, dir))) { | ||
if (canWriteToDirAndExists(dir)) | ||
@@ -30,0 +34,0 @@ return dir; |
{ | ||
"name": "@pnpm/global-bin-dir", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Finds a directory that is in PATH and we have permission to write to i", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5908
60