mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 14:25:17 +00:00
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:
37
index.js
37
index.js
@@ -499,29 +499,28 @@ class Pass {
|
||||
*/
|
||||
|
||||
_patch(passBuffer) {
|
||||
if (!Object.keys(this.props).length) {
|
||||
return Promise.resolve(passBuffer);
|
||||
}
|
||||
|
||||
const rgbValues = ["backgroundColor", "foregroundColor", "labelColor"];
|
||||
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) {
|
||||
Object.assign(passFile, this.props);
|
||||
} else {
|
||||
Object.keys(this.props).forEach(prop => {
|
||||
if (passFile[prop]) {
|
||||
if (passFile[prop] instanceof Array) {
|
||||
passFile[prop].push(...this.props[prop]);
|
||||
} else if (passFile[prop] instanceof Object) {
|
||||
Object.assign(passFile[prop], this.props[prop]);
|
||||
rgbValues.filter(v => this.props[v] && !isValidRGB(this.props[v])).forEach(v => delete this.props[v]);
|
||||
|
||||
if (this.shouldOverwrite) {
|
||||
Object.assign(passFile, this.props);
|
||||
} else {
|
||||
Object.keys(this.props).forEach(prop => {
|
||||
if (passFile[prop]) {
|
||||
if (passFile[prop] instanceof Array) {
|
||||
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 => {
|
||||
|
||||
Reference in New Issue
Block a user