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