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

Function installDependencies

packages/api/core/src/util/install-dependencies.ts:17–54  ·  view source on GitHub ↗
(
  pm: PMDetails,
  dir: string,
  deps: string[],
  depType = DepType.PROD,
  versionRestriction = DepVersionRestriction.RANGE,
)

Source from the content-addressed store, hash-verified

15}
16
17export async function installDependencies(
18 pm: PMDetails,
19 dir: string,
20 deps: string[],
21 depType = DepType.PROD,
22 versionRestriction = DepVersionRestriction.RANGE,
23): Promise<void> {
24 d(
25 'installing',
26 JSON.stringify(deps),
27 'in:',
28 dir,
29 `depType=${depType},versionRestriction=${versionRestriction},withPackageManager=${pm.executable}`,
30 );
31 if (deps.length === 0) {
32 d('nothing to install, stopping immediately');
33 return Promise.resolve();
34 }
35 const cmd = [pm.install].concat(deps);
36 if (depType === DepType.DEV) cmd.push(pm.dev);
37 if (versionRestriction === DepVersionRestriction.EXACT) cmd.push(pm.exact);
38
39 d('executing', JSON.stringify(cmd), 'in:', dir);
40 try {
41 await spawnPackageManager(pm, cmd, {
42 cwd: dir,
43 stdio: 'pipe',
44 });
45 } catch (err) {
46 if (err instanceof ExitError) {
47 throw new Error(
48 `Failed to install modules: ${JSON.stringify(deps)}\n\nWith output: ${err.message}\n${err.stderr ? err.stderr.toString() : ''}`,
49 );
50 } else {
51 throw err;
52 }
53 }
54}

Callers 5

import.tsFile · 0.90
init.tsFile · 0.90
initNPMFunction · 0.90

Calls 1

spawnPackageManagerFunction · 0.90

Tested by

no test coverage detected