MCPcopy
hub / github.com/electron/forge / checkPnpmConfig

Function checkPnpmConfig

packages/api/cli/src/util/check-system.ts:36–69  ·  view source on GitHub ↗

* Packaging an app with Electron Forge requires `node_modules` to be on disk. * With `pnpm`, this can be done in a few different ways. * * `node-linker=hoisted` replicates the behaviour of npm and Yarn Classic, while * users may choose to set `public-hoist-pattern` or `hoist-pattern` for advance

()

Source from the content-addressed store, hash-verified

34 * configuration purposes.
35 */
36async function checkPnpmConfig() {
37 const { pnpm } = PACKAGE_MANAGERS;
38 const hoistPattern = await spawnPackageManager(pnpm, [
39 'config',
40 'get',
41 'hoist-pattern',
42 ]);
43 const publicHoistPattern = await spawnPackageManager(pnpm, [
44 'config',
45 'get',
46 'public-hoist-pattern',
47 ]);
48
49 if (hoistPattern !== 'undefined' || publicHoistPattern !== 'undefined') {
50 d(
51 `Custom hoist pattern detected ${JSON.stringify({
52 hoistPattern,
53 publicHoistPattern,
54 })}, assuming that the user has configured pnpm to package dependencies.`,
55 );
56 return;
57 }
58
59 const nodeLinker = await spawnPackageManager(pnpm, [
60 'config',
61 'get',
62 'node-linker',
63 ]);
64 if (nodeLinker !== 'hoisted') {
65 throw new Error(
66 'When using pnpm, `node-linker` must be set to "hoisted" (or a custom `hoist-pattern` or `public-hoist-pattern` must be defined). Run `pnpm config set node-linker hoisted` to set this config value, or add it to your project\'s `.npmrc` file.',
67 );
68 }
69}
70
71async function checkYarnConfig() {
72 const { yarn } = PACKAGE_MANAGERS;

Callers 1

checkPackageManagerFunction · 0.85

Calls 1

spawnPackageManagerFunction · 0.90

Tested by

no test coverage detected