Socket
Socket
Sign inDemoInstall

tsc-watch

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsc-watch - npm Package Compare versions

Comparing version 4.1.0 to 4.2.0-rc1

0

client.js
module.exports = require('./lib/client');
setInterval(() => console.log(Math.random()), 1000);
setInterval(() => console.log(Math.random()), 1000);

@@ -0,0 +0,0 @@ {

#!/usr/bin/env node
require('./lib/tsc-watch');

@@ -0,0 +0,0 @@ function removeRunnerArgs(args) {

@@ -0,0 +0,0 @@ const { fork } = require('child_process');

@@ -0,0 +0,0 @@ const psTree = require('ps-tree');

@@ -0,0 +0,0 @@ const spawn = require('cross-spawn');

51

lib/stdout-manipulator.js

@@ -25,13 +25,13 @@ const stripAnsi = require('strip-ansi');

// coloring errors:
line = line.replace(typescriptErrorRegex, m => `\u001B[36m${m}\u001B[39m`); // Cyan
line = line.replace(typescriptPrettyErrorRegex, m => `\u001B[36m${m}\u001B[39m`); // Cyan
line = line.replace(typescriptErrorRegex, m => `\u001B[36m${m}\u001B[39m`); // Cyan
line = line.replace(typescriptPrettyErrorRegex, m => `\u001B[36m${m}\u001B[39m`); // Cyan
// completed with error:
line = line.replace(compilationCompleteWithErrorRegex, m => `\u001B[31m${m}\u001B[39m`); // Red
line = line.replace(compilationCompleteWithErrorRegex, m => `\u001B[31m${m}\u001B[39m`); // Red
// completed without error:
line = line.replace(compilationCompleteWithoutErrorRegex, m => `\u001B[32m${m}\u001B[39m`); // Green
line = line.replace(compilationCompleteWithoutErrorRegex, m => `\u001B[32m${m}\u001B[39m`); // Green
// usage
line = line.replace(tscUsageSyntaxRegex, m => `\u001B[33m${m}\u001B[39m`); // Yellow
line = line.replace(tscUsageSyntaxRegex, m => `\u001B[33m${m}\u001B[39m`); // Yellow

@@ -45,35 +45,24 @@ if (noClear && newCompilationRegex.test(line)) {

function print(noColors, noClear, lines) {
return lines.forEach(line => console.log(noColors ? line : color(line, noClear)));
function print(noColors, noClear, line) {
return console.log(noColors ? line : color(line, noClear));
}
function removeColors(lines) {
return lines.map(line => stripAnsi(line));
function isClear(line) {
const buffer = Buffer.from(line);
return buffer.length >= 2 && buffer[0] === 0x1b && buffer[1] === 0x63;
}
function isClear(buffer) {
return buffer && buffer.length === 2 && buffer[0] === 0x1b && buffer[1] === 0x63;
function manipulate(line) {
return line.replace(tscUsageSyntaxRegex, newAdditionToSyntax);
}
function manipulate(buffer) {
const lines = buffer
.toString()
.split('\n')
.filter(a => a.length > 0)
.map(a => a.replace(tscUsageSyntaxRegex, newAdditionToSyntax));
function detectState(line) {
const clearLine = stripAnsi(line);
const newCompilation = newCompilationRegex.test(clearLine);
const compilationError =
compilationCompleteWithErrorRegex.test(clearLine) ||
typescriptErrorRegex.test(clearLine) ||
typescriptPrettyErrorRegex.test(clearLine);
const compilationComplete = compilationCompleteRegex.test(clearLine);
return lines;
}
function detectState(lines) {
const clearLines = removeColors(lines);
const newCompilation = clearLines.some(line => newCompilationRegex.test(line));
const compilationError = clearLines.some(
line =>
compilationCompleteWithErrorRegex.test(line) ||
typescriptErrorRegex.test(line) ||
typescriptPrettyErrorRegex.test(line)
);
const compilationComplete = clearLines.some(line => compilationCompleteRegex.test(line));
return {

@@ -80,0 +69,0 @@ newCompilation: newCompilation,

@@ -9,2 +9,3 @@ #!/usr/bin/env node

const { manipulate, detectState, isClear, print } = require('./stdout-manipulator');
const readline = require('readline');

@@ -50,10 +51,14 @@ let firstTime = true;

const tscProcess = spawn(bin, [...args]);
tscProcess.stdout.on('data', buffer => {
if (noClear && isClear(buffer)) {
const rl = readline.createInterface({
input: tscProcess.stdout,
});
rl.on('line', function(input) {
if (noClear && isClear(input)) {
return;
}
const lines = manipulate(buffer);
print(noColors, noClear, lines);
const state = detectState(lines);
const line = manipulate(input);
print(noColors, noClear, line);
const state = detectState(line);
const newCompilation = state.newCompilation;

@@ -60,0 +65,0 @@ const compilationError = state.compilationError;

{
"name": "tsc-watch",
"version": "4.1.0",
"version": "4.2.0-rc1",
"description": "The TypeScript compiler with onSuccess command",

@@ -5,0 +5,0 @@ "scripts": {

@@ -6,3 +6,3 @@ [![Build Status](https://travis-ci.com/gilamran/tsc-watch.svg?branch=master)](https://travis-ci.com/gilamran/tsc-watch)

`tsc-watch` starts a TypeScript compiler with `--watch` parameter, with the ability to react to compilation status.
`tsc-watch` was created to allow an easy dev process with TypeScript. Commonly used to restart a node server, similar to nodemon but for TypeCcript.
`tsc-watch` was created to allow an easy dev process with TypeScript. Commonly used to restart a node server, similar to nodemon but for TypeScript.

@@ -9,0 +9,0 @@ | Argument | Description |

@@ -0,0 +0,0 @@ const fs = require('fs');

@@ -0,0 +0,0 @@ const { expect } = require('chai');

@@ -0,0 +0,0 @@ const { expect } = require('chai');

@@ -0,0 +0,0 @@ const { fork } = require('child_process');

@@ -0,0 +0,0 @@ const fse = require('fs-extra');

@@ -0,0 +0,0 @@ const { expect } = require('chai');

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc