Skip to content

Commit

Permalink
fix: plugin path (#101)
Browse files Browse the repository at this point in the history
* fix: plugin path

* chore: plugin package.json

* chore: del path

* chore: find importPath use path.resolve+require.resolve

Co-authored-by: 张荣杰 <[email protected]>
  • Loading branch information
wengeezhang and wengeezhang authored Jun 9, 2022
1 parent 47e504c commit e7424c2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/plugin/base.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Plugin, PluginConfigItem, PluginMetadata } from "./types";
import path from 'path';
type PluginMap = Map<string, BasePlugin>;

export class BasePlugin implements Plugin {
Expand All @@ -12,7 +13,7 @@ export class BasePlugin implements Plugin {
this.name = name;
let importPath = configItem.path ?? '';
if (configItem.package) {
importPath = require.resolve(configItem.package);
importPath = path.resolve(require.resolve(`${configItem.package}/package.json`), '..');
}
if (!importPath) {
throw new Error(`Plugin ${name} need have path or package field`);
Expand Down

0 comments on commit e7424c2

Please sign in to comment.