Skip to content

Commit

Permalink
Fixed issue #81 (No restart)
Browse files Browse the repository at this point in the history
  • Loading branch information
gilamran committed Feb 29, 2020
1 parent c07c75f commit 2724876
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions lib/stdout-manipulator.js
Expand Up @@ -45,9 +45,12 @@ function print(noColors, noClear, line) {
return console.log(noColors ? line : color(line, noClear));
}

function isClear(line) {
function deleteClear(line) {
const buffer = Buffer.from(line);
return buffer.length >= 2 && buffer[0] === 0x1b && buffer[1] === 0x63;
if (buffer.length >= 2 && buffer[0] === 0x1b && buffer[1] === 0x63) {
return line.substr(2);
}
return line;
}

function manipulate(line) {
Expand All @@ -72,7 +75,7 @@ function detectState(line) {

module.exports = {
print: print,
isClear: isClear,
deleteClear: deleteClear,
manipulate: manipulate,
detectState: detectState,
};
6 changes: 3 additions & 3 deletions lib/tsc-watch.js
Expand Up @@ -5,7 +5,7 @@ const nodeCleanup = require('node-cleanup');
const spawn = require('cross-spawn');
const run = require('./runner');
const { extractArgs } = require('./args-manager');
const { manipulate, detectState, isClear, print } = require('./stdout-manipulator');
const { manipulate, detectState, deleteClear, print } = require('./stdout-manipulator');
const readline = require('readline');

let firstTime = true;
Expand Down Expand Up @@ -52,8 +52,8 @@ const rl = readline.createInterface({
});

rl.on('line', function(input) {
if (noClear && isClear(input)) {
return;
if (noClear) {
input = deleteClear(input);
}

const line = manipulate(input);
Expand Down

0 comments on commit 2724876

Please sign in to comment.