This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a plugin to clear the terminal screen
## Name TerminalClearPlugin ## Description Clears the terminal output so that only the latest build information is displayed ## Options - saveHistory {Boolean} true - indicates whether to keep the terminal history or not
- Loading branch information
1 parent
d76bd18
commit c73fd0d
Showing
4 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Class representing a webpack plugin for clearing the terminal screen. | ||
* | ||
* @requires webpack version >=4 | ||
* @version 1.0.0 | ||
* @author janeRivas <[email protected]> | ||
* @license MIT | ||
*/ | ||
class TerminalClearPlugin { | ||
/** | ||
* @param {Boolean} [saveHistory=true] - indicates whether to keep the terminal history or not | ||
*/ | ||
constructor({ saveHistory = true } = { }) { | ||
this.saveHistory = saveHistory | ||
} | ||
|
||
/** | ||
* Installs the plugin. | ||
* https://webpack.js.org/contribute/writing-a-plugin/#basic-plugin-architecture | ||
*/ | ||
apply(compiler) { | ||
compiler.hooks.beforeCompile.tapAsync('TerminalClearPlugin', (params, callback) => { | ||
process.stdout.write(this.saveHistory ? '\x1B[H\x1B[2J' : '\x1B[2J\x1B[3J\x1B[H\x1Bc') | ||
callback() | ||
}) | ||
} | ||
} | ||
|
||
|
||
module.exports = new TerminalClearPlugin() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters