Removed early return in _patch since not needed (this.props is not the only property to be checked in _patch)

This commit is contained in:
alexandercerutti
2018-08-26 12:07:23 +02:00
parent 4e3fa748c1
commit 4ea50c5d95

View File

@@ -499,29 +499,28 @@ class Pass {
*/ */
_patch(passBuffer) { _patch(passBuffer) {
if (!Object.keys(this.props).length) {
return Promise.resolve(passBuffer);
}
const rgbValues = ["backgroundColor", "foregroundColor", "labelColor"];
let passFile = JSON.parse(passBuffer.toString("utf8")); let passFile = JSON.parse(passBuffer.toString("utf8"));
rgbValues.filter(v => this.props[v] && !isValidRGB(this.props[v])).forEach(v => delete this.props[v]); if (Object.keys(this.props).length) {
const rgbValues = ["backgroundColor", "foregroundColor", "labelColor"];
if (this.shouldOverwrite) { rgbValues.filter(v => this.props[v] && !isValidRGB(this.props[v])).forEach(v => delete this.props[v]);
Object.assign(passFile, this.props);
} else { if (this.shouldOverwrite) {
Object.keys(this.props).forEach(prop => { Object.assign(passFile, this.props);
if (passFile[prop]) { } else {
if (passFile[prop] instanceof Array) { Object.keys(this.props).forEach(prop => {
passFile[prop].push(...this.props[prop]); if (passFile[prop]) {
} else if (passFile[prop] instanceof Object) { if (passFile[prop] instanceof Array) {
Object.assign(passFile[prop], this.props[prop]); passFile[prop].push(...this.props[prop]);
} else if (passFile[prop] instanceof Object) {
Object.assign(passFile[prop], this.props[prop]);
}
} else {
passFile[prop] = this.props[prop];
} }
} else { });
passFile[prop] = this.props[prop]; }
}
});
} }
fieldsName.forEach(area => { fieldsName.forEach(area => {