Skip to content

Commit

Permalink
fix: automatically add profile reporter when profile option enabl…
Browse files Browse the repository at this point in the history
…ed (#94)

Co-Authored-By: Il Harper <[email protected]>
  • Loading branch information
pi0 and ilharp committed Dec 15, 2023
1 parent 31e8aab commit 762b65a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 0 additions & 2 deletions playground/index.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
// eslint-disable-next-line unicorn/import-style
import "chalk";
import "eslint";
import "standard-version";
1 change: 1 addition & 0 deletions playground/webpack.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const config = (name, color) => ({
color,
name,
reporters: ["fancy"],
profile: process.argv.includes("--profile"),
// reporter: {
// progress ({ state }) {
// if (lastProgress !== state.progress && state.progress % 5 === 0) {
Expand Down
8 changes: 8 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ export default class WebpackBarPlugin extends Webpack.ProgressPlugin {
return { reporter } as ReporterOpts;
});

// Add profile if neeed
if (
this.options.profile &&
!_reporters.some(({ reporter }) => reporter === "profile")
) {
_reporters.push({ reporter: "profile" });
}

// Resolve reporters
this.reporters = _reporters
.map(({ reporter, options = {} }) => {
Expand Down

0 comments on commit 762b65a

Please sign in to comment.