Skip to content
This repository was archived by the owner on Jan 2, 2023. It is now read-only.

Commit cffd310

Browse files
committed
Clean dist to remove old files
1 parent caa1bbb commit cffd310

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"test:unit": "jest --runInBand --verbose",
1111
"test:unit:watch": "jest --runInBand --watch --verbose",
1212
"build": "yarn build:esm && yarn build:cjs",
13+
"build:clean": "node --experimental-modules scripts/clean-dist.mjs",
1314
"build:esm": "tsc --module es6 --target es2018 --outDir dist/esm",
1415
"build:cjs": "tsc --module commonjs --target es5 --outDir dist/cjs",
1516
"build:umd": "tsc --module umd --target es5 --outDir dist/umd",

scripts/clean-dist.mjs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {
2+
existsSync,
3+
readdirSync,
4+
lstatSync,
5+
unlinkSync,
6+
rmdirSync,
7+
} from 'fs';
8+
import { join } from 'path';
9+
10+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
11+
const deleteFolderRecursive = (filePath) => {
12+
if (existsSync(filePath)) {
13+
readdirSync(filePath).forEach((file, _index) => {
14+
const curPath = join(filePath, file);
15+
if (lstatSync(curPath).isDirectory()) { // recurse
16+
deleteFolderRecursive(curPath);
17+
} else { // delete file
18+
unlinkSync(curPath);
19+
}
20+
});
21+
rmdirSync(filePath);
22+
}
23+
};
24+
25+
deleteFolderRecursive('./dist');

0 commit comments

Comments
 (0)