-
-
Notifications
You must be signed in to change notification settings - Fork 223
/
prune_modules.js
29 lines (26 loc) · 1.07 KB
/
prune_modules.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
29
const fs = require('fs')
const glob = require('fast-glob')
const { execSync } = require('child_process')
const dist = 'dist/'
const nm = 'node_modules/'
console.log('launching nm-prune') // must be run from this dir
const ya = dist + nm + 'yaml/dist/'
fs.renameSync(ya+'doc', ya+'do_c') // "hide" this folder from nm-prune
execSync('nm-prune --force -l', { cwd:'dist' })
fs.renameSync(ya+'do_c', ya+'doc')
process.chdir(dist)
console.log('more pruning')
fs.rmSync(nm+'node-forge/dist', {recursive:true})
fs.rmSync(nm+'node-forge/flash', {recursive:true})
fs.rmSync(nm+'axios/lib', {recursive:true})
fs.rmSync(nm+'react', {recursive:true})
fs.rmSync(nm+'yaml/browser', {recursive:true})
fs.rmSync(nm+'limiter/dist/esm', {recursive:true})
for (const fn of glob.sync(['**/*.map', '**/*.tsbuildinfo', '*.bak']))
fs.unlinkSync(fn)
console.log('pruning lodash')
fs.mkdirSync(nm+'lodash2')
fs.cpSync(nm+'lodash/package.json', nm+'lodash2/package.json')
fs.cpSync(nm+'lodash/lodash.min.js', nm+'lodash2/lodash.js')
fs.rmSync(nm+'lodash', {recursive:true})
fs.renameSync(nm+'lodash2', nm+'lodash')