Skip to content

Commit

Permalink
Merge pull request #391 from TrySound/drop-mkdirp
Browse files Browse the repository at this point in the history
Replace mkdirp with builtin recursive flag
  • Loading branch information
th0r committed Nov 8, 2020
2 parents 0188312 + 8509a61 commit d093666
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
5 changes: 0 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Expand Up @@ -43,7 +43,6 @@
"filesize": "^6.1.0",
"gzip-size": "^5.1.1",
"lodash": "^4.17.20",
"mkdirp": "^1.0.4",
"opener": "^1.5.2",
"ws": "^7.3.1"
},
Expand Down
4 changes: 2 additions & 2 deletions src/BundleAnalyzerPlugin.js
@@ -1,5 +1,5 @@
const fs = require('fs');
const path = require('path');
const mkdir = require('mkdirp');
const {bold} = require('chalk');

const Logger = require('./Logger');
Expand Down Expand Up @@ -80,7 +80,7 @@ class BundleAnalyzerPlugin {

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

try {
await writeStats(stats, statsFilepath);
Expand Down
7 changes: 3 additions & 4 deletions src/viewer.js
Expand Up @@ -6,7 +6,6 @@ const WebSocket = require('ws');
const _ = require('lodash');
const express = require('express');
const ejs = require('ejs');
const mkdir = require('mkdirp');
const {bold} = require('chalk');

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

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

mkdir.sync(path.dirname(reportFilepath));
fs.mkdirSync(path.dirname(reportFilepath), {recursive: true});
fs.writeFileSync(reportFilepath, reportHtml);

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

if (!chartData) return;

mkdir.sync(path.dirname(reportFilename));
fs.writeFileSync(reportFilename, JSON.stringify(chartData));
await fs.promises.mkdir(path.dirname(reportFilename), {recursive: true});
await fs.promises.writeFile(reportFilename, JSON.stringify(chartData));

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

0 comments on commit d093666

Please sign in to comment.