How to use the @ionic/utils-fs.readdir 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 / ios / utils / xcode.ts View on Github external
export async function getDeveloperDiskImagePath(version: string) {
  const xCodePath = await getXCodePath();
  const versionDirs = await readdir(`${xCodePath}/Platforms/iPhoneOS.platform/DeviceSupport/`);
  const versionPrefix = version.match(/\d+\.\d+/);
  if (versionPrefix === null) {
    throw new Exception(`Invalid iOS version: ${version}`);
  }
  // Can look like "11.2 (15C107)"
  for (const dir of versionDirs) {
    if (dir.includes(versionPrefix[0])) {
      return `${xCodePath}/Platforms/iPhoneOS.platform/DeviceSupport/${dir}/DeveloperDiskImage.dmg`;
    }
  }
  throw new Exception(`Unable to find Developer Disk Image path for SDK ${version}. Do you have the right version of Xcode?`);
}
github ionic-team / starters / src / utils / index.ts View on Github external
export async function getDirectories(p: string): Promise {
  const contents = await readdir(p);
  return filter(contents.map(f => path.resolve(p, f)), async f => (await stat(f)).isDirectory());
}
github ionic-team / native-run / src / android / utils / avd.ts View on Github external
export async function getAVDINIs(sdk: SDK): Promise<[string, AVDINI][]> {
  const debug = Debug(`${modulePrefix}:${getAVDINIs.name}`);

  const { avdHome } = sdk;

  if (!avdHome) {
    throw new SDKException(`No valid Android AVD home found.`, ERR_AVD_HOME_NOT_FOUND);
  }

  const contents = await readdir(avdHome);

  const iniFilePaths = contents
    .filter(f => pathlib.extname(f) === '.ini')
    .map(f => pathlib.resolve(avdHome, f));

  debug('Discovered AVD ini files: %O', iniFilePaths);

  const iniFiles = await Promise.all(
    iniFilePaths.map(async (f): Promise<[string, AVDINI | undefined]> => [f, await readINI(f, isAVDINI)])
  );

  const avdInis = iniFiles
    .filter((c): c is [string, AVDINI] => typeof c[1] !== 'undefined');

  return avdInis;
}