@pnpm/exec.lifecycle 1100.0.17 → 1100.1.0

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.
package/lib/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { runLifecycleHook, type RunLifecycleHookOptions } from './runLifecycleHook.js';
2
2
  import { runLifecycleHooksConcurrently, type RunLifecycleHooksConcurrentlyOptions } from './runLifecycleHooksConcurrently.js';
3
- export declare function makeNodeRequireOption(modulePath: string): {
3
+ export declare function makeNodeRequireOption(modulePath: string, env?: Record<string, string | undefined>): {
4
+ NODE_OPTIONS: string;
5
+ };
6
+ export declare function makeNodePackageMapOption(packageMapPath: string, env?: Record<string, string | undefined>): {
4
7
  NODE_OPTIONS: string;
5
8
  };
6
9
  export { runLifecycleHook, type RunLifecycleHookOptions, runLifecycleHooksConcurrently, type RunLifecycleHooksConcurrentlyOptions, };
package/lib/index.js CHANGED
@@ -1,11 +1,35 @@
1
1
  import { safeReadPackageJsonFromDir } from '@pnpm/pkg-manifest.reader';
2
2
  import { runLifecycleHook } from './runLifecycleHook.js';
3
3
  import { runLifecycleHooksConcurrently } from './runLifecycleHooksConcurrently.js';
4
- export function makeNodeRequireOption(modulePath) {
5
- let { NODE_OPTIONS } = process.env;
6
- NODE_OPTIONS = `${NODE_OPTIONS ?? ''} --require=${modulePath}`.trim();
4
+ export function makeNodeRequireOption(modulePath, env) {
5
+ let { NODE_OPTIONS } = env ?? process.env;
6
+ NODE_OPTIONS = `${NODE_OPTIONS ?? process.env.NODE_OPTIONS ?? ''} --require=${quotePathIfNeeded(modulePath)}`.trim();
7
7
  return { NODE_OPTIONS };
8
8
  }
9
+ export function makeNodePackageMapOption(packageMapPath, env) {
10
+ let { NODE_OPTIONS } = env ?? process.env;
11
+ NODE_OPTIONS = `${removeNodePackageMapOption(NODE_OPTIONS ?? process.env.NODE_OPTIONS ?? '')} --experimental-package-map=${quotePathIfNeeded(packageMapPath)}`.trim();
12
+ return { NODE_OPTIONS };
13
+ }
14
+ // Node's NODE_OPTIONS tokenizer splits on whitespace, treats `'` and `"` as
15
+ // quote delimiters, and uses `\` as an escape character. A bare path with a
16
+ // space, quote, or backslash (e.g. any Windows path) would therefore be
17
+ // mis-parsed. Wrap such paths in double quotes and escape `\` and `"` so the
18
+ // tokenizer reconstructs the literal path.
19
+ function quotePathIfNeeded(path) {
20
+ if (!/[\s"'\\]/.test(path))
21
+ return path;
22
+ return `"${path.replace(/(["\\])/g, '\\$1')}"`;
23
+ }
24
+ function removeNodePackageMapOption(nodeOptions) {
25
+ // The quoted-value patterns span backslash escapes (`\"`), matching the
26
+ // escaping `makeNodePackageMapOption` emits, so an existing flag whose path
27
+ // contains a quote is still stripped in full.
28
+ return nodeOptions
29
+ .replace(/(?:^|\s)--experimental-package-map=(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+)/g, '')
30
+ .replace(/(?:^|\s)--experimental-package-map\s+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+)/g, '')
31
+ .trim();
32
+ }
9
33
  export { runLifecycleHook, runLifecycleHooksConcurrently, };
10
34
  export async function runPostinstallHooks(opts) {
11
35
  const pkg = await safeReadPackageJsonFromDir(opts.pkgRoot);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/exec.lifecycle",
3
- "version": "1100.0.17",
3
+ "version": "1100.1.0",
4
4
  "description": "Package lifecycle hook runner",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -29,34 +29,34 @@
29
29
  "!*.map"
30
30
  ],
31
31
  "dependencies": {
32
- "@pnpm/npm-lifecycle": "1100.0.0-1",
32
+ "@pnpm/npm-lifecycle": "^1100.0.0",
33
33
  "chalk": "^5.6.2",
34
34
  "is-windows": "^1.0.2",
35
35
  "path-exists": "^5.0.0",
36
36
  "run-groups": "^5.0.0",
37
37
  "shlex": "^3.0.0",
38
- "@pnpm/bins.linker": "1100.0.13",
39
- "@pnpm/core-loggers": "1100.2.0",
38
+ "@pnpm/bins.linker": "1100.0.15",
40
39
  "@pnpm/error": "1100.0.0",
41
- "@pnpm/fetching.directory-fetcher": "1100.0.16",
42
- "@pnpm/pkg-manifest.reader": "1100.0.7",
40
+ "@pnpm/fetching.directory-fetcher": "1100.0.17",
41
+ "@pnpm/pkg-manifest.reader": "1100.0.8",
43
42
  "@pnpm/store.cafs-types": "1100.0.1",
44
- "@pnpm/store.controller-types": "1100.1.4",
45
- "@pnpm/types": "1101.3.1"
43
+ "@pnpm/core-loggers": "1100.2.1",
44
+ "@pnpm/types": "1101.3.2",
45
+ "@pnpm/store.controller-types": "1100.1.5"
46
46
  },
47
47
  "peerDependencies": {
48
- "@pnpm/logger": "^1001.0.1"
48
+ "@pnpm/logger": "^1100.0.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@jest/globals": "30.3.0",
51
+ "@jest/globals": "30.4.1",
52
52
  "@types/is-windows": "^1.0.2",
53
53
  "@zkochan/rimraf": "^4.0.0",
54
54
  "load-json-file": "^7.0.1",
55
- "@pnpm/exec.lifecycle": "1100.0.17",
56
- "@pnpm/prepare": "1100.0.15",
57
- "@pnpm/test-ipc-server": "1100.0.0",
55
+ "@pnpm/exec.lifecycle": "1100.1.0",
58
56
  "@pnpm/logger": "1100.0.0",
59
- "@pnpm/test-fixtures": "1100.0.0"
57
+ "@pnpm/test-fixtures": "1100.0.0",
58
+ "@pnpm/prepare": "1100.0.16",
59
+ "@pnpm/test-ipc-server": "1100.0.0"
60
60
  },
61
61
  "engines": {
62
62
  "node": ">=22.13"