Skip to content

Commit

Permalink
Merge branch 'main' into actions/tools-update-config.json
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 authored Jul 12, 2024
2 parents 28fac6c + 932bd4e commit b180743
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 165 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"semver": "^7.5.2",
"supports-color": "^9.0.0",
"tar": "^6.2.1",
"ts-node": "^10.0.0",
"tsx": "^4.16.2",
"typescript": "^5.3.3",
"undici": "^6.19.2",
"v8-compile-cache": "^2.3.0",
Expand All @@ -53,10 +53,10 @@
"undici-types": "6.x"
},
"scripts": {
"build": "run clean && run build:bundle && ts-node ./mkshims.ts",
"build": "run clean && run build:bundle && tsx ./mkshims.ts",
"build:bundle": "esbuild ./sources/_lib.ts --bundle --platform=node --target=node18.17.0 --external:corepack --outfile='./dist/lib/corepack.cjs' --resolve-extensions='.ts,.mjs,.js'",
"clean": "run rimraf dist shims",
"corepack": "ts-node ./sources/_cli.ts",
"corepack": "tsx ./sources/_cli.ts",
"lint": "eslint .",
"prepack": "yarn build",
"postpack": "run clean",
Expand Down
17 changes: 10 additions & 7 deletions sources/commands/Disable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,21 @@ export class DisableCommand extends Command<Context> {
? SupportedPackageManagerSetWithoutNpm
: this.names;

const allBinNames: Array<string> = [];

for (const name of new Set(names)) {
if (!isSupportedPackageManager(name))
throw new UsageError(`Invalid package manager name '${name}'`);

for (const binName of this.context.engine.getBinariesFor(name)) {
if (process.platform === `win32`) {
await this.removeWin32Link(installDirectory, binName);
} else {
await this.removePosixLink(installDirectory, binName);
}
}
const binNames = this.context.engine.getBinariesFor(name);
allBinNames.push(...binNames);
}

const removeLink = process.platform === `win32` ?
(binName: string) => this.removeWin32Link(installDirectory, binName) :
(binName: string) => this.removePosixLink(installDirectory, binName);

await Promise.all(allBinNames.map(removeLink));
}

async removePosixLink(installDirectory: string, binName: string) {
Expand Down
17 changes: 10 additions & 7 deletions sources/commands/Enable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,21 @@ export class EnableCommand extends Command<Context> {
? SupportedPackageManagerSetWithoutNpm
: this.names;

const allBinNames: Array<string> = [];

for (const name of new Set(names)) {
if (!isSupportedPackageManager(name))
throw new UsageError(`Invalid package manager name '${name}'`);

for (const binName of this.context.engine.getBinariesFor(name)) {
if (process.platform === `win32`) {
await this.generateWin32Link(installDirectory, distFolder, binName);
} else {
await this.generatePosixLink(installDirectory, distFolder, binName);
}
}
const binNames = this.context.engine.getBinariesFor(name);
allBinNames.push(...binNames);
}

const generateLink = process.platform === `win32` ?
(binName: string) => this.generateWin32Link(installDirectory, distFolder, binName) :
(binName: string) => this.generatePosixLink(installDirectory, distFolder, binName);

await Promise.all(allBinNames.map(generateLink));
}

async generatePosixLink(installDirectory: string, distFolder: string, binName: string) {
Expand Down
9 changes: 4 additions & 5 deletions sources/commands/InstallGlobal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ export class InstallGlobalCommand extends BaseCommand {
if (this.args.length === 0)
throw new UsageError(`No package managers specified`);

for (const arg of this.args) {
await Promise.all(this.args.map(arg => {
if (arg.endsWith(`.tgz`)) {
await this.installFromTarball(path.resolve(this.context.cwd, arg));
return this.installFromTarball(path.resolve(this.context.cwd, arg));
} else {
await this.installFromDescriptor(specUtils.parseSpec(arg, `CLI arguments`, {enforceExactVersion: false}));
return this.installFromDescriptor(specUtils.parseSpec(arg, `CLI arguments`, {enforceExactVersion: false}));
}
}
}));
}

log(locator: Locator) {
Expand Down Expand Up @@ -86,7 +86,6 @@ export class InstallGlobalCommand extends BaseCommand {
if (segments.length > 0 && segments[segments.length - 1] !== `.corepack`)
return;


if (segments.length < 3) {
hasShortEntries = true;
} else {
Expand Down
3 changes: 0 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,5 @@
"skipLibCheck": true,
"strict": true,
"target": "ES2022"
},
"ts-node": {
"transpileOnly": true
}
}
Loading

0 comments on commit b180743

Please sign in to comment.