Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
Clear terminal with each webpack rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
szwacz committed May 26, 2021
1 parent 25d9041 commit 6951e92
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion build/start.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
const childProcess = require("child_process");
const readline = require("readline");
const electron = require("electron");
const webpack = require("webpack");
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);
Expand All @@ -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 }));
}
});

0 comments on commit 6951e92

Please sign in to comment.