|
2 | 2 |
|
3 | 3 | import path from 'path';
|
4 | 4 | import os from 'os';
|
5 |
| -import fse from 'fs-extra'; |
| 5 | +import fs from 'fs/promises'; |
6 | 6 | import yargs from 'yargs';
|
7 | 7 | import Piscina from 'piscina';
|
8 | 8 | import micromatch from 'micromatch';
|
@@ -31,7 +31,8 @@ async function getWebpackSizes(args, config) {
|
31 | 31 | });
|
32 | 32 | // Clean and recreate the build directory
|
33 | 33 | const buildDir = path.join(rootDir, 'build');
|
34 |
| - await fse.emptyDir(buildDir); |
| 34 | + await fs.rm(buildDir, { recursive: true, force: true }); |
| 35 | + await fs.mkdir(buildDir, { recursive: true }); |
35 | 36 |
|
36 | 37 | if (
|
37 | 38 | !config ||
|
@@ -89,8 +90,8 @@ async function run(argv) {
|
89 | 90 | const bundleSizes = Object.fromEntries(webpackSizes.sort((a, b) => a[0].localeCompare(b[0])));
|
90 | 91 |
|
91 | 92 | // Ensure output directory exists
|
92 |
| - await fse.mkdirp(path.dirname(snapshotDestPath)); |
93 |
| - await fse.writeJSON(snapshotDestPath, bundleSizes, { spaces: 2 }); |
| 93 | + await fs.mkdir(path.dirname(snapshotDestPath), { recursive: true }); |
| 94 | + await fs.writeFile(snapshotDestPath, JSON.stringify(bundleSizes, null, 2)); |
94 | 95 |
|
95 | 96 | // eslint-disable-next-line no-console
|
96 | 97 | console.log(`Bundle size snapshot written to ${snapshotDestPath}`);
|
|
0 commit comments