1import path from 'path';
2
3import * as Log from '../log';
4import { FileNotifier } from '../utils/FileNotifier';
5import { ensureDirectoryAsync, removeAsync } from '../utils/dir';
6import { exportAppAsync } from './exportApp';
7import { Options } from './resolveOptions';
8
9export async function exportAsync(projectRoot: string, options: Options) {
10  // Ensure the output directory is created
11  const outputPath = path.resolve(projectRoot, options.outputDir);
12  // Delete the output directory if it exists
13  await removeAsync(outputPath);
14  // Create the output directory
15  await ensureDirectoryAsync(outputPath);
16
17  // Export the app
18  await exportAppAsync(projectRoot, options);
19
20  // Stop any file watchers to prevent the CLI from hanging.
21  FileNotifier.stopAll();
22
23  // Final notes
24  Log.log(`Export was successful. Your exported files can be found in ${options.outputDir}`);
25}
26