mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-16 07:25:38 +00:00
Changed how colors validation happens: now they will make validation throw if they have an incorrect value
This commit is contained in:
@@ -5,7 +5,7 @@ import * as Signature from "./Signature";
|
||||
import * as Strings from "./StringsUtils";
|
||||
import { getModelFolderContents } from "./parser";
|
||||
import { Stream } from "stream";
|
||||
import { isValidRGB, processDate } from "./utils";
|
||||
import { processDate } from "./utils";
|
||||
|
||||
/** Exporting for tests specs */
|
||||
export const propsSymbol = Symbol("props");
|
||||
@@ -516,30 +516,6 @@ export default class PKPass extends Bundle {
|
||||
) {
|
||||
const fileNames = Object.keys(this[filesSymbol]);
|
||||
|
||||
/**
|
||||
* Filtering colors props that have an
|
||||
* invalid RGB value
|
||||
*/
|
||||
|
||||
const passColors = [
|
||||
"backgroundColor",
|
||||
"foregroundColor",
|
||||
"labelColor",
|
||||
] as Array<keyof Schemas.PassColors>;
|
||||
|
||||
for (let i = 0; i < passColors.length; i++) {
|
||||
const colorProperty = passColors[i];
|
||||
const colorInProps = this[propsSymbol][colorProperty];
|
||||
|
||||
if (colorInProps && !isValidRGB(colorInProps)) {
|
||||
console.warn(
|
||||
`'${colorProperty}' property has been removed from pass.json as it has not a valid RGB-string value.`,
|
||||
);
|
||||
|
||||
delete this[propsSymbol][colorProperty];
|
||||
}
|
||||
}
|
||||
|
||||
const passJson = Buffer.from(JSON.stringify(this[propsSymbol]));
|
||||
super.addBuffer("pass.json", passJson);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user