From 6951e92d15472187976538ed98cb9d572ce426bc Mon Sep 17 00:00:00 2001 From: Jakub Szwacz Date: Wed, 26 May 2021 07:12:30 +0200 Subject: [PATCH] Clear terminal with each webpack rebuild --- build/start.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/build/start.js b/build/start.js index dbeb08c1..381eb1e1 100644 --- a/build/start.js +++ b/build/start.js @@ -1,4 +1,5 @@ const childProcess = require("child_process"); +const readline = require("readline"); const electron = require("electron"); const webpack = require("webpack"); const config = require("./webpack.app.config"); @@ -6,6 +7,15 @@ const config = require("./webpack.app.config"); const compiler = webpack(config({ development: true })); let electronStarted = false; +const clearTerminal = () => { + if (process.stdout.isTTY) { + const blankLines = "\n".repeat(process.stdout.rows); + console.log(blankLines); + readline.cursorTo(process.stdout, 0, 0); + readline.clearScreenDown(process.stdout); + } +}; + const watching = compiler.watch({}, (err, stats) => { if (err != null) { console.log(err); @@ -18,5 +28,8 @@ const watching = compiler.watch({}, (err, stats) => { }); } - console.log(stats.toString({ colors: true })); + if (stats != null) { + clearTerminal(); + console.log(stats.toString({ colors: true })); + } });