refactor: Replace _.unset with delete (#7813)

This commit is contained in:
Chris Villanueva 2020-06-03 12:07:28 -04:00 committed by GitHub
parent dc96b9a876
commit e39cdfdf02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -96,9 +96,9 @@ class PluginUninstall {
_.pull(plugins, this.options.pluginName);
if (_.isEmpty(plugins)) {
if (isArrayPluginsObject) {
_.unset(serverlessFileObj, 'plugins');
delete serverlessFileObj.plugins;
} else {
_.unset(serverlessFileObj.plugins, 'modules');
delete serverlessFileObj.plugins.modules;
}
}
return fse.writeJson(serverlessFilePath, serverlessFileObj);

View File

@ -145,13 +145,13 @@ const removeExistingArrayItem = (ymlFile, pathInYml, removeValue) =>
_.pull(arrayProperty, removeValue);
if (_.isEmpty(arrayProperty)) {
_.unset(currentNode, arrayPropertyName);
delete currentNode[arrayPropertyName];
pathInObjectTree.push(currentNode);
for (let i = pathInObjectTree.length - 1; i > 0; i--) {
if (Object.keys(pathInObjectTree[i]).length > 0) {
break;
}
_.unset(pathInObjectTree[i - 1], pathInYmlArray[i - 1]);
delete pathInObjectTree[i - 1][pathInYmlArray[i - 1]];
}
}