18d307f52SEvan Baconimport chalk from 'chalk'; 28d307f52SEvan Baconimport fs from 'fs'; 38d307f52SEvan Baconimport path from 'path'; 48d307f52SEvan Bacon 58d307f52SEvan Baconimport { logNewSection } from './ora'; 68d307f52SEvan Bacon 7*6caf5755SEvan Baconexport async function clearNodeModulesAsync(projectRoot: string) { 88d307f52SEvan Bacon // This step can take a couple seconds, if the installation logs are enabled (with EXPO_DEBUG) then it 98d307f52SEvan Bacon // ends up looking odd to see "Installing JavaScript dependencies" for ~5 seconds before the logs start showing up. 108d307f52SEvan Bacon const cleanJsDepsStep = logNewSection('Cleaning JavaScript dependencies'); 118d307f52SEvan Bacon const time = Date.now(); 128d307f52SEvan Bacon // nuke the node modules 138d307f52SEvan Bacon // TODO: this is substantially slower, we should find a better alternative to ensuring the modules are installed. 14*6caf5755SEvan Bacon await fs.promises.rm(path.join(projectRoot, 'node_modules'), { recursive: true, force: true }); 158d307f52SEvan Bacon cleanJsDepsStep.succeed( 168d307f52SEvan Bacon `Cleaned JavaScript dependencies ${chalk.gray(Date.now() - time + 'ms')}` 178d307f52SEvan Bacon ); 188d307f52SEvan Bacon} 19