mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
update
This commit is contained in:
1 parent
8389519249
commit
a5886ecb99
37 files changed
+940
-162
No files matched your search
@@ -0,0 +1,39 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import cluster from 'cluster';
|
||||
import fs from 'fs-extra';
|
||||
import { filter } from 'lodash';
|
||||
import { argv } from 'yargs';
|
||||
import * as hydro from 'hydrooj';
|
||||
|
||||
if (!cluster.isMaster) {
|
||||
// Forked by hydro
|
||||
hydro.load().catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
});
|
||||
} else {
|
||||
fs.ensureDirSync(path.resolve(os.homedir(), '.hydro'));
|
||||
const addonPath = path.resolve(os.homedir(), '.hydro', 'addon.json');
|
||||
let addons = filter(
|
||||
fs.readdirSync(path.resolve(__dirname, '../packages')),
|
||||
(i) => i !== 'hydrooj',
|
||||
).map((i) => `@hydrooj/${i}`);
|
||||
fs.writeFileSync(addonPath, JSON.stringify(addons, null, 2));
|
||||
|
||||
try {
|
||||
const ui = argv.ui as string || '@hydrooj/ui-default';
|
||||
require.resolve(ui);
|
||||
addons.push(ui);
|
||||
} catch (e) {
|
||||
console.error('Please also install @hydrooj/ui-default');
|
||||
}
|
||||
|
||||
addons = Array.from(new Set(addons));
|
||||
for (const addon of addons) hydro.addon(addon);
|
||||
(argv._[0] === 'cli' ? hydro.loadCli : hydro.load)().catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user