Skip to content

Commit

Permalink
version 1.1.37
Browse files Browse the repository at this point in the history
  • Loading branch information
gilamran committed Feb 8, 2019
1 parent 9357368 commit 353c87c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# @gilamran/tsc-watch CHANGELOG

## v1.1.37 - 8/2/2019

Fixed coloring issues

## v1.1.36 - 31/1/2019

`--watch` will be added to the end of the arguments (Thanks to @barkayal)
Expand Down
33 changes: 13 additions & 20 deletions lib/stdout-manipulator.js
Expand Up @@ -19,36 +19,29 @@ const newAdditionToSyntax = [
' --compiler PATH The PATH will be used instead of typescript compiler. Defaults typescript/bin/tsc.',
].join('\n');

function isError(line) {
return typescriptErrorRegex.test(line) || typescriptPrettyErrorRegex.test(line);
}

function color(line) {
if (isError(line)) {
return `\u001B[36m${line}\u001B[39m`; // Cyan
}
function color(line, noClear) {
// coloring errors:
line = line.replace(typescriptErrorRegex, m => `\u001B[36m${m}\u001B[39m`); // Cyan
line = line.replace(typescriptPrettyErrorRegex, m => `\u001B[36m${m}\u001B[39m`); // Cyan

if (compilationCompleteWithErrorRegex.test(line)) {
return `\u001B[31m${line}\u001B[39m`; // Red
}
// completed with error:
line = line.replace(compilationCompleteWithErrorRegex, m => `\u001B[31m${m}\u001B[39m`); // Red

if (compilationCompleteWithoutErrorRegex.test(line)) {
return `\u001B[32m${line}\u001B[39m`; // Green
}
// completed without error:
line = line.replace(compilationCompleteWithoutErrorRegex, m => `\u001B[32m${m}\u001B[39m`); // Green

if (tscUsageSyntaxRegex.test(line)) {
return `\u001B[33m${line}\u001B[39m`; // Yellow
}
// usage
line = line.replace(tscUsageSyntaxRegex, m => `\u001B[33m${m}\u001B[39m`); // Yellow

if (newCompilationRegex.test(line)) {
if (noClear && newCompilationRegex.test(line)) {
return '\n\n----------------------\n' + line;
}

return line;
}

function print(noColors, lines) {
return lines.forEach(line => console.log(noColors ? line : color(line)));
function print(noColors, noClear, lines) {
return lines.forEach(line => console.log(noColors ? line : color(line, noClear)));
}

function removeColors(lines) {
Expand Down
2 changes: 1 addition & 1 deletion lib/tsc-watch.js
Expand Up @@ -77,7 +77,7 @@ tscProcess.stdout.on('data', buffer => {
}

const lines = manipulate(buffer);
print(noColors, lines);
print(noColors, noClear, lines);
const { compilationError, compilationComplete } = detectState(lines);

if (compilationComplete) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "tsc-watch",
"version": "1.1.36",
"version": "1.1.37",
"description": "The TypeScript compiler with onSuccess command",
"scripts": {
"test": "mocha test/**/*.js"
Expand Down

0 comments on commit 353c87c

Please sign in to comment.