Skip to content

Commit 397fedc

Browse files
add support for array
1 parent c7b2669 commit 397fedc

File tree

3 files changed

+3802
-4
lines changed

3 files changed

+3802
-4
lines changed

index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const _ = require('lodash')
12
class serverlessPluginIfElse {
23
/**
34
*
@@ -110,10 +111,10 @@ class serverlessPluginIfElse {
110111
return;
111112
}
112113
}
113-
if (path[i] in item) {
114+
if (_.get(item, path[i])) {
114115
if (type == "remove") {
115116
this.serverless.cli.log(this.pluginName + " - Excluding: " + keyPath);
116-
delete item[path[i]];
117+
_.unset(item, [path[i]]);
117118
} else if (type == "set") {
118119
item[path[i]] = newValue;
119120
if (typeof newValue == "object") {

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
"eslint": "^7.20.0",
2121
"jest": "^26.6.3"
2222
},
23-
"dependencies": {},
23+
"dependencies": {
24+
"lodash": "^4.17.21"
25+
},
2426
"repository": {
2527
"type": "git",
2628
"url": "git+https://github.com/anantab/serverless-plugin-ifelse.git"
@@ -29,4 +31,4 @@
2931
"url": "https://github.com/anantab/serverless-plugin-ifelse/issues"
3032
},
3133
"homepage": "https://github.com/anantab/serverless-plugin-ifelse"
32-
}
34+
}

0 commit comments

Comments
 (0)