core: loader: support profile

This commit is contained in:
undefined committed 2024-06-07 06:08:43 +08:00
1 parent 1c8a6ee9ab
commit 8f0476e7cb
9 files changed
+73 -68

No files matched your search

+3 -3
View File
@@ -4,9 +4,9 @@ import path from 'path';
import { CAC } from 'cac';
import fs from 'fs-extra';
import { Logger } from '@hydrooj/utils';
import { getAddons, writeAddons } from '../options';
const logger = new Logger('addon');
const addonPath = path.resolve(os.homedir(), '.hydro', 'addon.json');
const addonDir = path.resolve(os.homedir(), '.hydro', 'addons');
export function register(cli: CAC) {
@@ -15,7 +15,7 @@ export function register(cli: CAC) {
console.log('Unknown operation.');
return;
}
let addons = JSON.parse(fs.readFileSync(addonPath).toString());
let addons = getAddons();
if (operation === 'create') {
const dir = `${addonDir}/${name || 'addon'}`;
fs.mkdirSync(dir, { recursive: true });
@@ -48,6 +48,6 @@ export function register(cli: CAC) {
addons = Array.from(new Set(addons));
logger.info('Current Addons: ');
console.log(addons);
fs.writeFileSync(addonPath, JSON.stringify(addons, null, 2));
writeAddons(addons);
});
}