How to use the @ionic/utils-fs.statSafe 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 / native-run / src / android / utils / avd.ts View on Github external
export async function copySkin(sdk: SDK, skin: string, skinpath: string): Promise {
  const debug = Debug(`${modulePrefix}:${copySkin.name}`);
  const skinsrc = pathlib.resolve(ASSETS_PATH, 'android', 'skins', skin);

  const stat = await statSafe(skinsrc);

  if (stat && stat.isDirectory()) {
    debug('Copying skin from %s to %s', skinsrc, skinpath);

    try {
      return await copy(skinsrc, skinpath);
    } catch (e) {
      debug('Error while copying skin: %O', e);
    }
  }

  throw new AVDException(`${skinpath} is an invalid skin.`, ERR_INVALID_SKIN);
}
github ionic-team / native-run / src / android / utils / avd.ts View on Github external
export async function validateSkin(sdk: SDK, skin: string, skinpath: string): Promise {
  const debug = Debug(`${modulePrefix}:${validateSkin.name}`);
  const p = pathlib.join(skinpath, 'layout');

  debug('Checking skin layout file: %s', p);

  const stat = await statSafe(p);

  if (stat && stat.isFile()) {
    return;
  }

  await copySkin(sdk, skin, skinpath);
}
github ionic-team / ionic-cli / packages / ionic / src / lib / integrations / cordova / project.ts View on Github external
const platforms = await filter(contents, async file => {
    const stat = await statSafe(path.join(platformsDir, file));
    return !file.startsWith('.') && typeof stat !== 'undefined' && stat.isDirectory();
  });
github ionic-team / native-run / src / android / utils / avd.ts View on Github external
export async function validateSystemImagePath(sdk: SDK, sysdir: string): Promise {
  const debug = Debug(`${modulePrefix}:${validateSystemImagePath.name}`);
  const p = pathlib.join(sdk.root, sysdir, 'package.xml');

  debug('Checking package.xml file: %s', p);

  const stat = await statSafe(p);

  if (!stat || !stat.isFile()) {
    throw new AVDException(`${p} is an invalid system image package.`, ERR_INVALID_SYSTEM_IMAGE);
  }
}