Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Commit

Permalink
fix(index): override function configs with their function-level params (
Browse files Browse the repository at this point in the history
#100)

Authored-by: ronnathaniel <ronnathaniel>
  • Loading branch information
ronnathaniel committed May 5, 2021
1 parent 57d60da commit 82405ac
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,10 @@ export default class ServerlessEpsagonPlugin {
// eslint-disable-next-line no-param-reassign
func.epsagon.wrapper = this.config().wrapper;
}
const handlerCode = generateWrapperCode(func, this.config());

const handlerCode = generateWrapperCode(func, this.config({
funcName: func.key,
}));
await writeFile(
join(
handlersFullDirPath,
Expand Down Expand Up @@ -303,11 +306,17 @@ export default class ServerlessEpsagonPlugin {
* Gets the plugin config.
* @returns {Object} The config object
*/
config() {
return Object.assign({
config({ funcName = '' } = {}) {
const funcs = this.sls.service.functions || {};
const funcConfig = (funcs[funcName] || {}).epsagon || {};
const epsagonConfig = (this.sls.service.custom || {}).epsagon || {};

return {
metadataOnly: 'false',
handlersDirName: 'epsagon_handlers',
}, (this.sls.service.custom || {}).epsagon || {});
...epsagonConfig,
...funcConfig,
};
}

/**
Expand Down

0 comments on commit 82405ac

Please sign in to comment.