mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: allow require module from plugin dir
This commit is contained in:
4 files changed
+11
-6
No files matched your search
@@ -2,8 +2,9 @@
|
||||
require('@hydrooj/utils/lib/register');
|
||||
|
||||
const packageBasedir = require('path').resolve(__dirname, '..');
|
||||
const { homedir } = require('os');
|
||||
const { default: hook } = require('require-resolve-hook');
|
||||
const { bypass } = hook(/^(hydrooj|@hydrooj\/utils|cordis|lodash|js-yaml)($|\/)/, (id) => {
|
||||
const { bypass } = hook(/^(hydrooj|@hydrooj|cordis|lodash|js-yaml)($|\/)/, (id) => {
|
||||
if (id.startsWith('hydrooj/src')) {
|
||||
console.log('module require via %s is deprecated.', id);
|
||||
if (process.env.DEV) {
|
||||
@@ -24,7 +25,11 @@ const { bypass } = hook(/^(hydrooj|@hydrooj\/utils|cordis|lodash|js-yaml)($|\/)/
|
||||
try {
|
||||
return require.resolve(id, { paths: [`${process.cwd()}/node_modules`] });
|
||||
} catch (e) {
|
||||
return id;
|
||||
try {
|
||||
return require.resolve(id.replace(/^@hydrooj\//, './'), { paths: [`${homedir()}/.hydro/addons`] });
|
||||
} catch (er) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "4.9.4",
|
||||
"version": "4.9.5",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/plugin-api",
|
||||
"module": "src/plugin-api",
|
||||
|
||||
@@ -83,8 +83,8 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadTool
|
||||
super(props);
|
||||
if (!availableLangs[this.props.editorLang]) {
|
||||
// preference not allowed
|
||||
const key = keys.filter((i) => availableLangs[i].pretest)
|
||||
.find((i) => availableLangs[i].pretest.split('.')[0] === this.props.editorLang.split('.')[0]);
|
||||
const key = this.props.editorLang ? keys.filter((i) => availableLangs[i].pretest)
|
||||
.find((i) => availableLangs[i].pretest.split('.')[0] === this.props.editorLang.split('.')[0]) : '';
|
||||
this.props.setEditorLanguage(key || keys[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/ui-default",
|
||||
"version": "4.48.8",
|
||||
"version": "4.48.9",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "index.ts",
|
||||
|
||||
Reference in new issue
Block a user