Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function runColorsConfig(colorsPath: string, colors: readonly ResolvedColorSource[]): Promise {
await ensureDir(pathlib.dirname(colorsPath));
const colorsDocument = await resolveColorsDocument(colorsPath);
const root = colorsDocument.getroot();
for (const color of colors) {
let colorElement = root.find(`color[@name='${color.name}']`);
if (!colorElement) {
debug('Creating node for %o', color.name);
colorElement = et.SubElement(root, 'color');
}
colorElement.set('name', color.name);
colorElement.text = color.color;
}
await write(colorsPath, colorsDocument);
export async function generateImageResource(type: ResourceType, platform: Platform, resourcesDirectory: string, config: ResourcesTypeConfig, image: ImageSourceData, schema: ImageSchema, errstream?: NodeJS.WritableStream): Promise {
const { pipeline, metadata } = image;
const { src, format, width, height } = schema;
const dest = pathlib.join(resourcesDirectory, src);
await ensureDir(pathlib.dirname(dest));
await generateImage({ src: dest, format, width, height }, pipeline.clone(), metadata, errstream);
return {
type,
format,
width,
height,
src: dest,
platform,
nodeName: config.nodeName,
nodeAttributes: config.nodeAttributes,
indexAttribute: config.indexAttribute,
};
}