Skip to content

Commit 7a11801

Browse files
committed
Replace mkdirp with builtin recursive flag
In node 10.12 mkdir got new recursive flag which provides the same functionality as mkdirp. See here https://nodejs.org/api/fs.html#fs_fs_mkdir_path_options_callback Also node 10 got builtin promisified `fs` utilities. See here https://nodejs.org/api/fs.html#fs_fs_promises_api
1 parent 6a67468 commit 7a11801

3 files changed

Lines changed: 5 additions & 7 deletions

File tree

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"filesize": "^6.1.0",
4444
"gzip-size": "^5.1.1",
4545
"lodash": "^4.17.20",
46-
"mkdirp": "^1.0.4",
4746
"opener": "^1.5.2",
4847
"ws": "^7.3.1"
4948
},

src/BundleAnalyzerPlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
const fs = reqiore('fs');
12
const path = require('path');
2-
const mkdir = require('mkdirp');
33
const {bold} = require('chalk');
44

55
const Logger = require('./Logger');
@@ -80,7 +80,7 @@ class BundleAnalyzerPlugin {
8080

8181
async generateStatsFile(stats) {
8282
const statsFilepath = path.resolve(this.compiler.outputPath, this.opts.statsFilename);
83-
mkdir.sync(path.dirname(statsFilepath));
83+
await fs.promises.mkdir(path.dirname(statsFilepath), { recursive: true });
8484

8585
try {
8686
await writeStats(stats, statsFilepath);

src/viewer.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const WebSocket = require('ws');
66
const _ = require('lodash');
77
const express = require('express');
88
const ejs = require('ejs');
9-
const mkdir = require('mkdirp');
109
const {bold} = require('chalk');
1110

1211
const Logger = require('./Logger');
@@ -163,7 +162,7 @@ async function generateReport(bundleStats, opts) {
163162

164163
const reportFilepath = path.resolve(bundleDir || process.cwd(), reportFilename);
165164

166-
mkdir.sync(path.dirname(reportFilepath));
165+
fs.mkdirSync(path.dirname(reportFilepath), { recursive: true });
167166
fs.writeFileSync(reportFilepath, reportHtml);
168167

169168
logger.info(`${bold('Webpack Bundle Analyzer')} saved report to ${bold(reportFilepath)}`);
@@ -187,8 +186,8 @@ async function generateJSONReport(bundleStats, opts) {
187186

188187
if (!chartData) return;
189188

190-
mkdir.sync(path.dirname(reportFilename));
191-
fs.writeFileSync(reportFilename, JSON.stringify(chartData));
189+
await fs.promises.mkdir(path.dirname(reportFilename), { recursive: true });
190+
await fs.promises.writeFileSync(reportFilename, JSON.stringify(chartData));
192191

193192
logger.info(`${bold('Webpack Bundle Analyzer')} saved JSON report to ${bold(reportFilename)}`);
194193
}

0 commit comments

Comments
 (0)