Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 3x 3x 3x 3x 3x 3x 3x 3x | import fs from 'fs'; import path from 'path'; import chalk from 'chalk'; import { removeDirs } from './fileutils'; import { logTask } from '../common'; import { askQuestion, generateOptions, finishQuestion } from './prompt'; const cleanProjectModules = (c, skipQuestion = false) => new Promise((resolve, reject) => { logTask('cleanProjectModules'); const pathsToRemove = [ c.paths.project.nodeModulesDir, path.join(c.paths.project.dir, 'package-lock.json') ]; let msg = chalk.red('./node_modules\n./package-lock.json\n'); const packagesFolder = path.join(c.paths.project.dir, 'packages'); if (fs.existsSync(packagesFolder)) { fs.readdirSync(packagesFolder).forEach((dir) => { if (dir === '.DS_Store') { pathsToRemove.push(path.join(packagesFolder, dir)); msg += chalk.red(`./packages/${dir}\n`); } else { pathsToRemove.push(path.join(packagesFolder, dir, 'node_modules')); pathsToRemove.push(path.join(packagesFolder, dir, 'package-lock.json')); msg += chalk.red(`./packages/${dir}/node_modules\n./packages/${dir}/package-lock.json\n`); } }); } if (skipQuestion) { removeDirs(pathsToRemove).then(() => resolve()).catch(e => reject(e)); } else { askQuestion(`Following files/folders will be removed:\n\n${msg}\npress (ENTER) to confirm`) .then(() => { finishQuestion(); removeDirs(pathsToRemove).then(() => resolve()) .catch(e => reject(e)); }) .catch(e => reject(e)); } }); export { cleanProjectModules }; |