mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: fix oauth redirect
This commit is contained in:
1 parent
10dd5d28d5
commit
92c62cb118
6 files changed
+67
-112
No files matched your search
@@ -24,33 +24,31 @@ process.on('unhandledRejection', logger.error);
|
||||
process.on('uncaughtException', logger.error);
|
||||
|
||||
export function addon(addonPath: string, prepend = false) {
|
||||
if (!(fs.existsSync(addonPath) && fs.statSync(addonPath).isFile())) {
|
||||
try {
|
||||
// Is a npm package
|
||||
const packagejson = require.resolve(`${addonPath}/package.json`);
|
||||
// eslint-disable-next-line import/no-dynamic-require
|
||||
const payload = require(packagejson);
|
||||
const name = payload.name.startsWith('@hydrooj/') ? payload.name.split('@hydrooj/')[1] : payload.name;
|
||||
global.Hydro.version[name] = payload.version;
|
||||
const modulePath = path.dirname(packagejson);
|
||||
const publicPath = path.resolve(modulePath, 'public');
|
||||
if (fs.existsSync(publicPath)) {
|
||||
global.publicDirs[prepend ? 'push' : 'unshift'](publicPath);
|
||||
const targets = fs.readdirSync(publicPath);
|
||||
for (const target of targets) {
|
||||
if (global.Hydro.ui.manifest[target] && !prepend) {
|
||||
global.Hydro.ui.manifest[target] = publicPath;
|
||||
} else if (!global.Hydro.ui.manifest[target]) {
|
||||
global.Hydro.ui.manifest[target] = publicPath;
|
||||
}
|
||||
try {
|
||||
// Is a npm package
|
||||
const packagejson = require.resolve(`${addonPath}/package.json`);
|
||||
// eslint-disable-next-line import/no-dynamic-require
|
||||
const payload = require(packagejson);
|
||||
const name = payload.name.startsWith('@hydrooj/') ? payload.name.split('@hydrooj/')[1] : payload.name;
|
||||
global.Hydro.version[name] = payload.version;
|
||||
const modulePath = path.dirname(packagejson);
|
||||
const publicPath = path.resolve(modulePath, 'public');
|
||||
if (fs.existsSync(publicPath)) {
|
||||
global.publicDirs[prepend ? 'push' : 'unshift'](publicPath);
|
||||
const targets = fs.readdirSync(publicPath);
|
||||
for (const target of targets) {
|
||||
if (global.Hydro.ui.manifest[target] && !prepend) {
|
||||
global.Hydro.ui.manifest[target] = publicPath;
|
||||
} else if (!global.Hydro.ui.manifest[target]) {
|
||||
global.Hydro.ui.manifest[target] = publicPath;
|
||||
}
|
||||
}
|
||||
global.addons[prepend ? 'unshift' : 'push'](modulePath);
|
||||
} catch (e) {
|
||||
logger.error(`Addon not found: ${addonPath}`);
|
||||
logger.error(e);
|
||||
}
|
||||
} else logger.error(`Addon not found: ${addonPath}`);
|
||||
global.addons[prepend ? 'unshift' : 'push'](modulePath);
|
||||
} catch (e) {
|
||||
logger.error(`Addon not found: ${addonPath}`);
|
||||
logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
export function addScript(name: string, description: string) {
|
||||
|
||||
Reference in new issue
Block a user