Skip to content

Commit

Permalink
Merge pull request #2 from ashwinaggarwal/bugfix/1-allow-falsy-prop-v…
Browse files Browse the repository at this point in the history
…alues

fix(plugin): #1 allow falsy property values to be replaced
  • Loading branch information
anantab authored Jan 18, 2019
2 parents 2c163ac + d26f7d7 commit 78e136f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
27 changes: 26 additions & 1 deletion __tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,29 @@ describe("Test Serverless IfElse Plugin With Condition Set 2", () => {
});
});

describe("Test Serverless IfElse Plugin With Condition Set 3", () => {
beforeAll(() => {
const condition = getConditions("condition3");
serverless = getServerless();
serverless.service.custom.serverlessIfElse = condition;
const serverlessIfElse = new serverlessPluginIfElse(serverless);
serverlessIfElse.applyConditions();
});

it("It Should Set Serverless Properties in Set when If condition Matches and the serverless property is falsy boolean value ", () => {
expect(serverless.service.custom.customCertificate.enabled).toBeTruthy();
});
});

const getServerless = function () {
return {
service: {
service: "Serverless Condition",
custom: {
serverlessExclude: []
serverlessExclude: [],
customCertificate: {
enabled: false
}
},
provider: {
name: "aws",
Expand Down Expand Up @@ -191,6 +208,14 @@ const getConditions = function (condition) {
"functions.func3": '"true" == "true"',
}
}
],
condition3: [
{
If: '"true"=="true"',
Set: {
"custom.customCertificate.enabled": "true",
},
}
]
};
return conditions[condition];
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class serverlessPluginIfElse {
return;
}
}
if (item[path[i]]) {
if (path[i] in item) {
if (type == "remove") {
this.serverless.cli.log(this.pluginName + " - Excluding: " + keyPath);
delete item[path[i]];
Expand Down

0 comments on commit 78e136f

Please sign in to comment.