mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
3b450f1632
* Took IconsProcessor out of ManifestProcessor. * Converted IconsProcessor into ImageObjectProcessor. * Made extractValue a separate resource, as it's used by multiple processors. * Taught manifest processor about splash_screens. * icons member now uses ImageObjectProcessor. * Icon tests are now ImageProcessor tests. * Fixed a few typos.
35 lines
1.0 KiB
JavaScript
35 lines
1.0 KiB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
/*
|
|
* Helper function extracts values from manifest members
|
|
* and reports conformance violations.
|
|
*/
|
|
|
|
function extractValue({
|
|
objectName,
|
|
object,
|
|
property,
|
|
expectedType,
|
|
trim
|
|
}, console) {
|
|
const value = object[property];
|
|
const isArray = Array.isArray(value);
|
|
// We need to special-case "array", as it's not a JS primitive.
|
|
const type = (isArray) ? 'array' : typeof value;
|
|
if (type !== expectedType) {
|
|
if (type !== 'undefined') {
|
|
let msg = `Expected the ${objectName}'s ${property} `;
|
|
msg += `member to be a ${expectedType}.`;
|
|
console.log(msg);
|
|
}
|
|
return undefined;
|
|
}
|
|
// Trim string and returned undefined if the empty string.
|
|
const shouldTrim = expectedType === 'string' && value && trim;
|
|
if (shouldTrim) {
|
|
return value.trim() || undefined;
|
|
}
|
|
return value;
|
|
}
|