-
Notifications
You must be signed in to change notification settings - Fork 3
/
clean.js
28 lines (25 loc) · 1.11 KB
/
clean.js
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
const { globSync } = require('glob')
const path = require('node:path')
const fs = require('node:fs')
process.stdout.write('Cleaning package folders\n')
process.stdout.write('\nRemoving TypeScript build info files\n')
const tsBuildInfoFiles = globSync(['./**/*.tsbuildinfo','./**/.tsbuildinfo'])
if (tsBuildInfoFiles.length > 0)
tsBuildInfoFiles.forEach(infoFile => {
const file = path.resolve(path.join(process.cwd(), infoFile))
fs.rmSync(file)
process.stdout.write(` - Removed ${ infoFile }\n`)
})
else
process.stdout.write(` - No TypeScript build info files found\n`)
process.stdout.write('\nRemoving build folders from within packages\n')
const buildFolders = globSync('./**/{build,dist,bin,.rollup.cache}/')
if (buildFolders.length > 0)
buildFolders.forEach(folderPath => {
const fullFolderPath = path.resolve(path.join(process.cwd(), folderPath))
process.stdout.write(` - Removing folder ${ folderPath }`)
fs.rmSync(fullFolderPath, { recursive: true })
process.stdout.write(` - done\n`)
})
else
process.stdout.write(` - No build folders found\n`)