How to use the @expo/config.fileExists function in @expo/config

To help you get started, we’ve selected a few @expo/config 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 expo / expo-cli / packages / expo-optimize / src / assets.ts View on Github external
async function readAssetJsonAsync(
  projectDir: string
): Promise<{ assetJson: JsonFile; assetInfo: AssetOptimizationState }> {
  const dirPath = join(projectDir, '.expo-shared');

  ensureDirSync(dirPath);

  const assetJson = new JsonFile(join(dirPath, 'assets.json'));
  if (!fileExists(assetJson.file)) {
    console.log();
    console.log(
      chalk.magenta(
        `\u203A Creating ${chalk.bold('.expo-shared/assets.json')} in the project's root directory.`
      )
    );
    console.log(
      chalk.magenta`\u203A This file is autogenerated and should not be edited directly.`
    );
    console.log(
      chalk.magenta`\u203A You should commit this to git so that asset state is shared between collaborators.`
    );
    console.log();

    await assetJson.writeAsync({});
  }
github expo / expo-cli / packages / expo-optimize / src / assets.ts View on Github external
export async function isProjectOptimized(
  projectDir: string,
  options: OptimizationOptions
): Promise {
  if (!fileExists(join(projectDir, '.expo-shared/assets.json'))) {
    return false;
  }
  const { selectedFiles } = await getAssetFilesAsync(projectDir, options);
  const { assetInfo } = await readAssetJsonAsync(projectDir);

  for (const file of selectedFiles) {
    const hash = calculateHash(file);
    if (!assetInfo[hash]) {
      return false;
    }
  }

  return true;
}