Skip to content

Commit e37d0b0

Browse files
author
GitHub Actions
committed
chore: Update dist
1 parent e64c8a6 commit e37d0b0

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

dist/index.js

+30-3
Original file line numberDiff line numberDiff line change
@@ -191,16 +191,43 @@ function findAppSpecKey(obj, keyName) {
191191
throw new Error(`AppSpec file must include property '${keyName}'`);
192192
}
193193

194-
function undefinedOrNullReplacer(_, value) {
195-
if (value === null || value === undefined) {
194+
function isEmptyValue(value) {
195+
if (value === null || value === undefined || value === '') {
196+
return true;
197+
}
198+
199+
if (Array.isArray(value) && value.length === 0) {
200+
return true;
201+
}
202+
203+
if (typeof value === 'object' && Object.values(value).length === 0) {
204+
return true;
205+
}
206+
207+
return false;
208+
}
209+
210+
function emptyValueReplacer(_, value) {
211+
if (isEmptyValue(value)) {
212+
return undefined;
213+
}
214+
215+
if (typeof value === 'object') {
216+
for (var childValue of Object.values(value)) {
217+
if (!isEmptyValue(childValue)) {
218+
// the object has at least one non-empty property
219+
return value;
220+
}
221+
}
222+
// the object has no non-empty property
196223
return undefined;
197224
}
198225

199226
return value;
200227
}
201228

202229
function cleanNullKeys(obj) {
203-
return JSON.parse(JSON.stringify(obj, undefinedOrNullReplacer));
230+
return JSON.parse(JSON.stringify(obj, emptyValueReplacer));
204231
}
205232

206233
function removeIgnoredAttributes(taskDef) {

0 commit comments

Comments
 (0)