Skip to content

Commit

Permalink
fix: when install plugin in devDependencies cant use plugin (#70)
Browse files Browse the repository at this point in the history
* chore: add test code

* chore: add test code

* chore: improve code coverage to 95%

* fix: when install p plugin in devDependencies cant use plugin
  • Loading branch information
Stevenzwzhai authored and cpselvis committed Feb 12, 2019
1 parent 5c93c5b commit 9819083
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/core/loadPlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ class Plugin {
const ctx = this.ctx;
const packagePath = pathFn.join(ctx.baseDir, 'package.json');
const pluginDir = ctx.pluginDir;
const extend = function (target, source) {
for (var obj in source) {
target[obj] = source[obj];
}
return target;
};

// Make sure package.json exists
return fs.exists(packagePath).then(function (exist) {
Expand All @@ -50,7 +56,7 @@ class Plugin {
// Read package.json and find dependencies
return fs.readFile(packagePath).then(function (content) {
const json = JSON.parse(content);
const deps = json.dependencies || json.devDependencies || {};
const deps = extend(json.dependencies || {}, json.devDependencies || {});

return Object.keys(deps);
});
Expand Down

0 comments on commit 9819083

Please sign in to comment.