Skip to content

Commit 3c0af2b

Browse files
authored
Fixes the corepack binary (#16)
1 parent b592a86 commit 3c0af2b

File tree

3 files changed

+10
-23
lines changed

3 files changed

+10
-23
lines changed

.vscode/settings.json

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"eslint.nodePath": ".yarn/sdks",
88
"typescript.enablePromptUseWorkspaceTsdk": true,
99
"editor.codeActionsOnSave": {
10-
"source.fixAll": true,
1110
"source.fixAll.eslint": true
1211
}
1312
}

mkshims.ts

+8-18
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
1-
import cmdShim from '@zkochan/cmd-shim';
2-
import fs from 'fs';
3-
import {SupportedPackageManagers} from 'sources/types';
1+
import cmdShim from '@zkochan/cmd-shim';
2+
import fs from 'fs';
43

5-
import config from './config.json';
4+
import {Engine} from './sources/Engine';
5+
import {SupportedPackageManagerSet} from './sources/types';
6+
7+
const engine = new Engine();
68

79
async function main() {
8-
for (const packageManager of Object.keys(config.definitions) as Array<SupportedPackageManagers>) {
9-
const binSet = new Set<string>();
10-
11-
for (const spec of Object.values(config.definitions[packageManager].ranges)) {
12-
if (Array.isArray(spec.bin)) {
13-
for (const entry of spec.bin) {
14-
binSet.add(entry);
15-
}
16-
} else {
17-
for (const entry of Object.keys(spec.bin)) {
18-
binSet.add(entry);
19-
}
20-
}
21-
}
10+
for (const packageManager of SupportedPackageManagerSet) {
11+
const binSet = engine.getBinariesFor(packageManager);
2212

2313
for (const binaryName of binSet) {
2414
const entryPath = `${__dirname}/dist/${binaryName}.js`;

sources/main.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ export function runMain(argv: Array<string>) {
9595
});
9696
}
9797

98-
declare const __non_webpack_require__: any;
99-
100-
if (typeof __non_webpack_require__ === `undefined` && process.mainModule === module)
98+
// Using `eval` to be sure that Webpack doesn't transform it
99+
if (process.mainModule === eval(`module`))
101100
runMain(process.argv.slice(2));
102-

0 commit comments

Comments
 (0)