clean-dependencies.js
1 const path = require('path'); 2 3 const CONFIG = require('../config'); 4 5 module.exports = function() { 6 // We can't require fs-extra or glob if `script/bootstrap` has never been run, 7 // because they are third party modules. This is okay because cleaning 8 // dependencies only makes sense if dependencies have been installed at least 9 // once. 10 const fs = require('fs-extra'); 11 const glob = require('glob'); 12 13 const apmDependenciesPath = path.join(CONFIG.apmRootPath, 'node_modules'); 14 console.log(`Cleaning ${apmDependenciesPath}`); 15 fs.removeSync(apmDependenciesPath); 16 17 const atomDependenciesPath = path.join( 18 CONFIG.repositoryRootPath, 19 'node_modules' 20 ); 21 console.log(`Cleaning ${atomDependenciesPath}`); 22 fs.removeSync(atomDependenciesPath); 23 24 const scriptDependenciesPath = path.join( 25 CONFIG.scriptRootPath, 26 'node_modules' 27 ); 28 console.log(`Cleaning ${scriptDependenciesPath}`); 29 fs.removeSync(scriptDependenciesPath); 30 31 const bundledPackageDependenciesPaths = path.join( 32 CONFIG.repositoryRootPath, 33 'packages', 34 '**', 35 'node_modules' 36 ); 37 for (const bundledPackageDependencyPath of glob.sync( 38 bundledPackageDependenciesPaths 39 )) { 40 fs.removeSync(bundledPackageDependencyPath); 41 } 42 };