Fixes the corepack binary (#16)

This commit is contained in:
Maël Nison 2020-09-30 01:07:37 +02:00 committed by GitHub
parent b592a8673d
commit 3c0af2b36b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 23 deletions

View File

@ -7,7 +7,6 @@
"eslint.nodePath": ".yarn/sdks", "eslint.nodePath": ".yarn/sdks",
"typescript.enablePromptUseWorkspaceTsdk": true, "typescript.enablePromptUseWorkspaceTsdk": true,
"editor.codeActionsOnSave": { "editor.codeActionsOnSave": {
"source.fixAll": true,
"source.fixAll.eslint": true "source.fixAll.eslint": true
} }
} }

View File

@ -1,24 +1,14 @@
import cmdShim from '@zkochan/cmd-shim'; import cmdShim from '@zkochan/cmd-shim';
import fs from 'fs'; import fs from 'fs';
import {SupportedPackageManagers} from 'sources/types';
import config from './config.json'; import {Engine} from './sources/Engine';
import {SupportedPackageManagerSet} from './sources/types';
const engine = new Engine();
async function main() { async function main() {
for (const packageManager of Object.keys(config.definitions) as Array<SupportedPackageManagers>) { for (const packageManager of SupportedPackageManagerSet) {
const binSet = new Set<string>(); const binSet = engine.getBinariesFor(packageManager);
for (const spec of Object.values(config.definitions[packageManager].ranges)) {
if (Array.isArray(spec.bin)) {
for (const entry of spec.bin) {
binSet.add(entry);
}
} else {
for (const entry of Object.keys(spec.bin)) {
binSet.add(entry);
}
}
}
for (const binaryName of binSet) { for (const binaryName of binSet) {
const entryPath = `${__dirname}/dist/${binaryName}.js`; const entryPath = `${__dirname}/dist/${binaryName}.js`;

View File

@ -95,8 +95,6 @@ export function runMain(argv: Array<string>) {
}); });
} }
declare const __non_webpack_require__: any; // Using `eval` to be sure that Webpack doesn't transform it
if (process.mainModule === eval(`module`))
if (typeof __non_webpack_require__ === `undefined` && process.mainModule === module)
runMain(process.argv.slice(2)); runMain(process.argv.slice(2));