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

Function checkPackageManager

packages/api/cli/src/util/check-system.ts:108–135  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

106};
107
108export async function checkPackageManager() {
109 const pm = await resolvePackageManager();
110 const version = pm.version ?? (await spawnPackageManager(pm, ['--version']));
111 const versionString = version.toString().trim();
112
113 const range =
114 ALLOWLISTED_VERSIONS[pm.executable][process.platform] ??
115 ALLOWLISTED_VERSIONS[pm.executable].all;
116 if (!semver.valid(version)) {
117 d(`Invalid semver-string while checking version: ${version}`);
118 throw new Error(
119 `Could not check ${pm.executable} version "${version}", assuming incompatible`,
120 );
121 }
122 if (!semver.satisfies(version, range, { includePrerelease: true })) {
123 throw new Error(
124 `Incompatible version of ${pm.executable} detected: "${version}" must be in range ${range}`,
125 );
126 }
127
128 if (pm.executable === 'pnpm') {
129 await checkPnpmConfig();
130 } else if (pm.executable === 'yarn') {
131 await checkYarnConfig();
132 }
133
134 return `${pm.executable}@${versionString}`;
135}
136
137/**
138 * Some people know their system is OK and don't appreciate the 800ms lag in

Callers 2

checkSystemFunction · 0.85

Calls 4

resolvePackageManagerFunction · 0.90
spawnPackageManagerFunction · 0.90
checkPnpmConfigFunction · 0.85
checkYarnConfigFunction · 0.85

Tested by

no test coverage detected