@pnpm/config 13.13.4 → 13.13.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ export declare function checkGlobalBinDir(globalBinDir: string, { env, shouldAllowWrite }: {
2
+ env: Record<string, string | undefined>;
3
+ shouldAllowWrite?: boolean;
4
+ }): Promise<void>;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.checkGlobalBinDir = void 0;
7
+ const fs_1 = require("fs");
8
+ const path_1 = __importDefault(require("path"));
9
+ const error_1 = __importDefault(require("@pnpm/error"));
10
+ const can_write_to_dir_1 = require("can-write-to-dir");
11
+ const path_name_1 = __importDefault(require("path-name"));
12
+ async function checkGlobalBinDir(globalBinDir, { env, shouldAllowWrite }) {
13
+ if (!env[path_name_1.default]) {
14
+ throw new error_1.default('NO_PATH_ENV', `Couldn't find a global directory for executables because the "${path_name_1.default}" environment variable is not set.`);
15
+ }
16
+ if (!await globalBinDirIsInPath(globalBinDir, env)) {
17
+ throw new error_1.default('GLOBAL_BIN_DIR_NOT_IN_PATH', `The configured global bin directory "${globalBinDir}" is not in PATH`);
18
+ }
19
+ if (shouldAllowWrite && !canWriteToDirAndExists(globalBinDir)) {
20
+ throw new error_1.default('PNPM_DIR_NOT_WRITABLE', `The CLI has no write access to the pnpm home directory at ${globalBinDir}`);
21
+ }
22
+ }
23
+ exports.checkGlobalBinDir = checkGlobalBinDir;
24
+ async function globalBinDirIsInPath(globalBinDir, env) {
25
+ const dirs = env[path_name_1.default]?.split(path_1.default.delimiter) ?? [];
26
+ if (dirs.some((dir) => areDirsEqual(globalBinDir, dir)))
27
+ return true;
28
+ const realGlobalBinDir = await fs_1.promises.realpath(globalBinDir);
29
+ return dirs.some((dir) => areDirsEqual(realGlobalBinDir, dir));
30
+ }
31
+ const areDirsEqual = (dir1, dir2) => path_1.default.relative(dir1, dir2) === '';
32
+ function canWriteToDirAndExists(dir) {
33
+ try {
34
+ return (0, can_write_to_dir_1.sync)(dir);
35
+ }
36
+ catch (err) { // eslint-disable-line
37
+ if (err.code !== 'ENOENT')
38
+ throw err;
39
+ return false;
40
+ }
41
+ }
42
+ //# sourceMappingURL=checkGlobalBinDir.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkGlobalBinDir.js","sourceRoot":"","sources":["../src/checkGlobalBinDir.ts"],"names":[],"mappings":";;;;;;AAAA,2BAAmC;AACnC,gDAAuB;AACvB,wDAAmC;AACnC,uDAAwD;AACxD,0DAA4B;AAErB,KAAK,UAAU,iBAAiB,CACrC,YAAoB,EACpB,EAAE,GAAG,EAAE,gBAAgB,EAA2E;IAElG,IAAI,CAAC,GAAG,CAAC,mBAAI,CAAC,EAAE;QACd,MAAM,IAAI,eAAS,CAAC,aAAa,EAC/B,iEAAiE,mBAAI,oCAAoC,CAAC,CAAA;KAC7G;IACD,IAAI,CAAC,MAAM,oBAAoB,CAAC,YAAY,EAAE,GAAG,CAAC,EAAE;QAClD,MAAM,IAAI,eAAS,CAAC,4BAA4B,EAAE,wCAAwC,YAAY,kBAAkB,CAAC,CAAA;KAC1H;IACD,IAAI,gBAAgB,IAAI,CAAC,sBAAsB,CAAC,YAAY,CAAC,EAAE;QAC7D,MAAM,IAAI,eAAS,CAAC,uBAAuB,EAAE,6DAA6D,YAAY,EAAE,CAAC,CAAA;KAC1H;AACH,CAAC;AAdD,8CAcC;AAED,KAAK,UAAU,oBAAoB,CAAE,YAAoB,EAAE,GAAuC;IAChG,MAAM,IAAI,GAAG,GAAG,CAAC,mBAAI,CAAC,EAAE,KAAK,CAAC,cAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAA;IACnD,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;QAAE,OAAO,IAAI,CAAA;IACpE,MAAM,gBAAgB,GAAG,MAAM,aAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAA;IACxD,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC,CAAA;AAChE,CAAC;AAED,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,EAAE,CAClD,cAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,CAAA;AAElC,SAAS,sBAAsB,CAAE,GAAW;IAC1C,IAAI;QACF,OAAO,IAAA,uBAAa,EAAC,GAAG,CAAC,CAAA;KAC1B;IAAC,OAAO,GAAQ,EAAE,EAAE,sBAAsB;QACzC,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ;YAAE,MAAM,GAAG,CAAA;QACpC,OAAO,KAAK,CAAA;KACb;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/config",
3
- "version": "13.13.4",
3
+ "version": "13.13.5",
4
4
  "description": "Gets configuration options for pnpm",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "homepage": "https://github.com/pnpm/pnpm/blob/main/packages/config#readme",
25
25
  "dependencies": {
26
- "@pnpm/npm-conf": "1.0.1",
26
+ "@pnpm/npm-conf": "1.0.2",
27
27
  "@pnpm/constants": "5.0.0",
28
28
  "@pnpm/error": "2.1.0",
29
29
  "@pnpm/global-bin-dir": "3.0.1",
@@ -39,7 +39,7 @@
39
39
  "which": "^2.0.2"
40
40
  },
41
41
  "devDependencies": {
42
- "@pnpm/config": "13.13.4",
42
+ "@pnpm/config": "13.13.5",
43
43
  "@pnpm/prepare": "0.0.37",
44
44
  "@types/ramda": "0.27.39",
45
45
  "@types/which": "^2.0.0",