Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace mkdirp with builtin recursive flag #391

Merged
merged 4 commits into from Nov 8, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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",
th0r marked this conversation as resolved.
Show resolved Hide resolved
"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