Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Delete 'packages/**/node_modules' in script/clean #18602

Merged
merged 1 commit into from Dec 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions script/lib/clean-dependencies.js
Expand Up @@ -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}`)
Expand All @@ -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)
}
}