Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add corepack cleanup command #363

Merged
merged 9 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions sources/commands/Cache.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {Command} from 'clipanion';
import fs from 'fs';

import {getInstallFolder} from '../folderUtils';
import type {Context} from '../main';

export class CacheCommand extends Command<Context> {
static paths = [
[`cache`, `clean`],
aduh95 marked this conversation as resolved.
Show resolved Hide resolved
];

static usage = Command.Usage({
description: `Cleans Corepack cache`,
details: `
Removes Corepack cache directory from your local disk.
`,
});

async execute() {
await fs.promises.rm(getInstallFolder(), {recursive: true, force: true});
}
}
2 changes: 2 additions & 0 deletions sources/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {BaseContext, Builtins, Cli, Command, Option, UsageError} from 'clipanion
import {version as corepackVersion} from '../package.json';

import {Engine} from './Engine';
import {CacheCommand} from './commands/Cache';
import {DisableCommand} from './commands/Disable';
import {EnableCommand} from './commands/Enable';
import {InstallGlobalCommand} from './commands/InstallGlobal';
Expand Down Expand Up @@ -117,6 +118,7 @@ export async function runMain(argv: Array<string>) {
cli.register(Builtins.HelpCommand);
cli.register(Builtins.VersionCommand);

cli.register(CacheCommand);
cli.register(DisableCommand);
cli.register(EnableCommand);
cli.register(InstallGlobalCommand);
Expand Down