13d6e487dSEvan Baconimport { ModPlatform } from '@expo/config-plugins'; 23d6e487dSEvan Baconimport fs from 'fs'; 33d6e487dSEvan Baconimport path from 'path'; 43d6e487dSEvan Bacon 53d6e487dSEvan Baconimport { promptToClearMalformedNativeProjectsAsync } from '../prebuild/clearNativeFolder'; 63d6e487dSEvan Baconimport { prebuildAsync } from '../prebuild/prebuildAsync'; 73d6e487dSEvan Baconimport { profile } from '../utils/profile'; 83d6e487dSEvan Bacon 93d6e487dSEvan Baconexport async function ensureNativeProjectAsync( 103d6e487dSEvan Bacon projectRoot: string, 113d6e487dSEvan Bacon { platform, install }: { platform: ModPlatform; install?: boolean } 123d6e487dSEvan Bacon) { 133d6e487dSEvan Bacon // If the user has an empty android folder then the project won't build, this can happen when they delete the prebuild files in git. 143d6e487dSEvan Bacon // Check to ensure most of the core files are in place, and prompt to remove the folder if they aren't. 153d6e487dSEvan Bacon await profile(promptToClearMalformedNativeProjectsAsync)(projectRoot, [platform]); 163d6e487dSEvan Bacon 173d6e487dSEvan Bacon // If the project doesn't have native code, prebuild it... 183d6e487dSEvan Bacon if (!fs.existsSync(path.join(projectRoot, platform))) { 193d6e487dSEvan Bacon await prebuildAsync(projectRoot, { 203d6e487dSEvan Bacon install: !!install, 213d6e487dSEvan Bacon platforms: [platform], 223d6e487dSEvan Bacon }); 23*c4ef02aeSEvan Bacon } else { 24*c4ef02aeSEvan Bacon return true; 253d6e487dSEvan Bacon } 26*c4ef02aeSEvan Bacon return false; 273d6e487dSEvan Bacon} 28