Socket
Socket
Sign inDemoInstall

clean-terminal-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clean-terminal-webpack-plugin - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

27

index.js

@@ -1,6 +0,8 @@

"use strict";
'use strict';
class CleanTerminalPlugin {
constructor(options = {}) {
this.message = options.message;
const {message, onlyInWatchMode = true} = options;
this.message = message;
this.onlyInWatchMode = onlyInWatchMode;
}

@@ -10,9 +12,9 @@

if (compiler.hooks) {
compiler.hooks.afterCompile.tap("CleanTerminalPlugin", () => {
if (process.env.NODE_ENV !== "production") this.clearConsole();
compiler.hooks.afterCompile.tap('CleanTerminalPlugin', () => {
if (this.shouldClearConsole(compiler)) this.clearConsole();
});
} else {
// backwards compatible version of compiler.hooks
compiler.plugin("emit", (_, done) => {
if (process.env.NODE_ENV !== "production") this.clearConsole();
compiler.plugin('emit', (_, done) => {
if (this.shouldClearConsole()) this.clearConsole();
done();

@@ -23,5 +25,14 @@ });

shouldClearConsole(compiler) {
if (this.onlyInWatchMode) return compile.watchMode;
else
return (
process.env.NODE_ENV !== 'production' &&
process.env.options.mode !== 'production'
);
}
clearConsole() {
const clear = "\x1B[2J\x1B[3J\x1B[H";
const output = this.message ? clear + this.message + "\n\n" : clear;
const clear = '\x1B[2J\x1B[3J\x1B[H';
const output = this.message ? clear + this.message + '\n\n' : clear;
process.stdout.write(output);

@@ -28,0 +39,0 @@ }

{
"name": "clean-terminal-webpack-plugin",
"version": "1.1.0",
"version": "2.0.0",
"description": "Cleans your terminal output during development to only show the latest build information.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -30,5 +30,6 @@ # Clean Terminal Webpack Plugin

| key | type | required | description |
| --- | --- | --- | --- |
| message | String | false | Message to be printend. |
| key | type | required | defaults | description |
| --- | --- | --- | --- | --- |
| message | String | no | `undefined` | Message to be printed |
| onlyInWatchMode | Boolean | no | `true` | Only clear the screen if webpack is in watch mode |

@@ -47,6 +48,7 @@ ## Example

new CleanTerminalPlugin({
message: `dev server running on http://${HOST}:${PORT}`
message: `dev server running on http://${HOST}:${PORT}`,
onlyInWatchMode: false
})
]
};
```
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc