Skip to content

Commit

Permalink
fix(lesy-plugin-config): add missing setter function
Browse files Browse the repository at this point in the history
  • Loading branch information
lokesh-coder committed Sep 16, 2020
1 parent 830198f commit 51624dd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/plugins/lesy-plugin-config/src/middlewares/config.mw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@ const path = require("path");
export default {
on: "INIT",
run(data: any) {
const newData = { ...data };
const localConfig = data.config;
Object.defineProperty(data, "config", {
set(value) {
newData.config = value;
},
get() {
const { rcFile } = require("rc-config-loader");
const pluginConfig = localConfig["@lesy/lesy-plugin-config"];
const name =
(pluginConfig && pluginConfig.name) || path.parse(data.root).name;
(pluginConfig && pluginConfig.name) || path.parse(newData.root).name;

const { config: c = {} } =
rcFile(name, {
cwd: data.root,
configFileName: `${data.root}/${name}`,
cwd: newData.root,
configFileName: `${newData.root}/${name}`,
defaultExtension: [".json", ".yml", ".js"],
packageJSON: {
fieldName: name,
Expand All @@ -22,6 +26,6 @@ export default {
return { ...c, ...localConfig };
},
});
return data;
return newData;
},
};

0 comments on commit 51624dd

Please sign in to comment.