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

Commit

Permalink
Clean dist to remove old files
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRuf committed Jan 21, 2020
1 parent caa1bbb commit cffd310
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"test:unit": "jest --runInBand --verbose",
"test:unit:watch": "jest --runInBand --watch --verbose",
"build": "yarn build:esm && yarn build:cjs",
"build:clean": "node --experimental-modules scripts/clean-dist.mjs",
"build:esm": "tsc --module es6 --target es2018 --outDir dist/esm",
"build:cjs": "tsc --module commonjs --target es5 --outDir dist/cjs",
"build:umd": "tsc --module umd --target es5 --outDir dist/umd",
Expand Down
25 changes: 25 additions & 0 deletions scripts/clean-dist.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {
existsSync,
readdirSync,
lstatSync,
unlinkSync,
rmdirSync,
} from 'fs';
import { join } from 'path';

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
const deleteFolderRecursive = (filePath) => {
if (existsSync(filePath)) {
readdirSync(filePath).forEach((file, _index) => {
const curPath = join(filePath, file);
if (lstatSync(curPath).isDirectory()) { // recurse
deleteFolderRecursive(curPath);
} else { // delete file
unlinkSync(curPath);
}
});
rmdirSync(filePath);
}
};

deleteFolderRecursive('./dist');

0 comments on commit cffd310

Please sign in to comment.