mirror of
https://github.com/strapi/strapi.git
synced 2025-09-04 14:23:03 +00:00
Merge pull request #10868 from strapi/v4/plugin-api/local-plugin-loading
Append strapi.dir to plugin path if relative
This commit is contained in:
commit
52bc4642b8
@ -15,7 +15,7 @@ module.exports = ({ env }) => ({
|
|||||||
},
|
},
|
||||||
myplugin: {
|
myplugin: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
resolve: `${__dirname}/../plugins/myplugin`,
|
resolve: `./plugins/myplugin`, // From the root of the project
|
||||||
config: {
|
config: {
|
||||||
testConf: 3,
|
testConf: 3,
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { dirname, join } = require('path');
|
const { dirname, join, resolve } = require('path');
|
||||||
const { statSync, existsSync } = require('fs');
|
const { statSync, existsSync } = require('fs');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const { get, has, pick, pickBy, defaultsDeep, map, prop, pipe } = require('lodash/fp');
|
const { get, has, pick, pickBy, defaultsDeep, map, prop, pipe } = require('lodash/fp');
|
||||||
@ -29,9 +29,9 @@ const toDetailedDeclaration = declaration => {
|
|||||||
try {
|
try {
|
||||||
pathToPlugin = dirname(require.resolve(declaration.resolve));
|
pathToPlugin = dirname(require.resolve(declaration.resolve));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (existsSync(declaration.resolve) && statSync(declaration.resolve).isDirectory()) {
|
pathToPlugin = resolve(strapi.dir, declaration.resolve);
|
||||||
pathToPlugin = declaration.resolve;
|
|
||||||
} else {
|
if (!existsSync(pathToPlugin) || !statSync(pathToPlugin).isDirectory()) {
|
||||||
throw new Error(`${declaration.resolve} couldn't be resolved`);
|
throw new Error(`${declaration.resolve} couldn't be resolved`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user