mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: add hydrooj uninstall command
This commit is contained in:
1 parent
d21ae767dd
commit
bd1034eff8
3 files changed
+47
-29
No files matched your search
@@ -175,6 +175,23 @@ if (!argv.args[0] || argv.args[0] === 'cli') {
|
||||
lastUpdate: Date.now(),
|
||||
}));
|
||||
});
|
||||
cli.command('uninstall [package]').action(async (name) => {
|
||||
if (!name) {
|
||||
cli.outputHelp();
|
||||
return;
|
||||
}
|
||||
if (yarnVersion !== 1) throw new Error('Yarn 1 is required.');
|
||||
const addonDir = path.join(hydroPath, 'addons');
|
||||
fs.ensureDirSync(addonDir);
|
||||
const plugins = fs.readdirSync(addonDir);
|
||||
if (!plugins.includes(name)) {
|
||||
throw new Error(`Plugin ${name} not found or not installed with \`hydrooj install\`.`);
|
||||
}
|
||||
const newAddonPath = path.join(addonDir, name);
|
||||
child.execSync(`hydrooj addon remove '${newAddonPath}'`, { stdio: 'inherit' });
|
||||
fs.removeSync(newAddonPath);
|
||||
console.log(`Successfully uninstalled ${name}.`);
|
||||
});
|
||||
cli.help();
|
||||
cli.parse();
|
||||
if (!cli.matchedCommand) {
|
||||
|
||||
Reference in new issue
Block a user