From 065cb690c05f8a5e71a4464b08eaada6c88005c2 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 19 Dec 2018 10:04:35 -0800 Subject: [PATCH] Delete 'packages/**/node_modules' in script/clean --- script/lib/clean-dependencies.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/script/lib/clean-dependencies.js b/script/lib/clean-dependencies.js index 72007cf04..5b64e5e89 100644 --- a/script/lib/clean-dependencies.js +++ b/script/lib/clean-dependencies.js @@ -3,10 +3,12 @@ const path = require('path') const CONFIG = require('../config') module.exports = function () { - // We can't require fs-extra if `script/bootstrap` has never been run, because - // it's a third party module. This is okay because cleaning dependencies only - // makes sense if dependencies have been installed at least once. + // We can't require fs-extra or glob if `script/bootstrap` has never been run, + // because they are third party modules. This is okay because cleaning + // dependencies only makes sense if dependencies have been installed at least + // once. const fs = require('fs-extra') + const glob = require('glob') const apmDependenciesPath = path.join(CONFIG.apmRootPath, 'node_modules') console.log(`Cleaning ${apmDependenciesPath}`) @@ -19,4 +21,9 @@ module.exports = function () { const scriptDependenciesPath = path.join(CONFIG.scriptRootPath, 'node_modules') console.log(`Cleaning ${scriptDependenciesPath}`) fs.removeSync(scriptDependenciesPath) + + const bundledPackageDependenciesPaths = path.join(CONFIG.repositoryRootPath, 'packages', '**', 'node_modules') + for (const bundledPackageDependencyPath of glob.sync(bundledPackageDependenciesPaths)) { + fs.removeSync(bundledPackageDependencyPath) + } }