-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
Copy pathbuild-clean.js
40 lines (36 loc) · 1.02 KB
/
build-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
29
30
31
32
33
34
35
36
37
38
39
40
/* eslint import/no-extraneous-dependencies: ["error", {"devDependencies": true}] */
const exec = require('exec-sh');
const getOutput = require('./get-output.js');
async function buildClean(project, cb) {
if (process.env.NODE_ENV === 'development' && project !== 'core') {
cb();
return;
}
const output = `${getOutput()}/${project}`;
const toRemove = [
"find **/*.js -type f -not -name 'postinstall.js' -print0 | xargs -0 -I {} rm -v {}",
"find *.js -type f -not -name 'postinstall.js' -print0 | xargs -0 -I {} rm -v {}",
'**/*.ts',
'*.ts',
'**/*.svelte',
'*.svelte',
'**/*.css',
'*.css',
'**/*.less',
'*.less',
'**/*.map',
'*.map',
'cjs',
'esm',
'components',
'less',
'modules',
'types/*.ts',
'types/components',
'types/modules',
'types/shared',
].map((command) => (command.includes('find') ? command : `rm -rf ${command}`));
await exec.promise(`cd ${output} && ${toRemove.join(' && ')}`);
if (cb) cb();
}
module.exports = buildClean;