How to use the @ionic/utils-fs.ensureDir function in @ionic/utils-fs

To help you get started, we’ve selected a few @ionic/utils-fs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ionic-team / cordova-res / src / config.ts View on Github external
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);
github ionic-team / cordova-res / src / platform.ts View on Github external
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,
  };
}