Socket
Socket
Sign inDemoInstall

tsc-watch

Package Overview
Dependencies
20
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.3.1 to 4.4.0

tsc-watch-client-example.js

2

CHANGELOG.md
# @gilamran/tsc-watch CHANGELOG
## v4.4.0 - 26/5/ 2021
tsc-watch is now listenning to message and reacts to them.
## v4.3.1 - 26/5/2021

@@ -4,0 +6,0 @@

@@ -0,1 +1,2 @@

console.log('Generating random number every sec');
setInterval(() => console.log(Math.random()), 1000);

@@ -0,1 +1,3 @@

console.log('Generating random number every sec');
setInterval(() => console.log(Math.random()), 1000);

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

this.tsc = fork(require.resolve('./tsc-watch.js'), args, { stdio: 'inherit' });
this.tsc.on('message', msg => this.emit(msg));
this.tsc.on('message', (msg) => this.emit(msg));
}

@@ -17,4 +17,28 @@

}
runOnCompilationCompleteCommand() {
if (this.tsc) {
this.tsc.send('run-on-compilation-complete-command');
}
}
runOnFirstSuccessCommand() {
if (this.tsc) {
this.tsc.send('run-on-first-success-command');
}
}
runOnFailureCommand() {
if (this.tsc) {
this.tsc.send('run-on-failure-command');
}
}
runOnSuccessCommand() {
if (this.tsc) {
this.tsc.send('run-on-success-command');
}
}
}
module.exports = TscWatchClient;

@@ -37,2 +37,26 @@ #!/usr/bin/env node

function runOnCompilationComplete() {
if (onCompilationComplete) {
compilationCompleteKiller = run(onCompilationComplete);
}
}
function runOnFailureCommand() {
if (onFailureCommand) {
failureKiller = run(onFailureCommand);
}
}
function runOnFirstSuccessCommand() {
if (onFirstSuccessCommand) {
firstSuccessKiller = run(onFirstSuccessCommand);
}
}
function runOnSuccessCommand() {
if (onSuccessCommand) {
successKiller = run(onSuccessCommand);
}
}
let bin;

@@ -55,3 +79,3 @@ try {

rl.on('line', function(input) {
rl.on('line', function (input) {
if (noClear) {

@@ -72,11 +96,7 @@ input = deleteClear(input);

killProcesses(false).then(() => {
if (onCompilationComplete) {
compilationCompleteKiller = run(onCompilationComplete);
}
runOnCompilationComplete();
if (compilationErrorSinceStart) {
Signal.emitFail();
if (onFailureCommand) {
failureKiller = run(onFailureCommand);
}
runOnFailureCommand();
} else {

@@ -86,11 +106,7 @@ if (firstTime) {

Signal.emitFirstSuccess();
if (onFirstSuccessCommand) {
firstSuccessKiller = run(onFirstSuccessCommand);
}
runOnFirstSuccessCommand();
}
Signal.emitSuccess();
if (onSuccessCommand) {
successKiller = run(onSuccessCommand);
}
runOnSuccessCommand();
}

@@ -101,2 +117,37 @@ });

if (typeof process.on === 'function') {
process.on('message', (msg) => {
let promise;
let func;
switch (msg) {
case 'run-on-compilation-complete-command':
promise = compilationCompleteKiller ? compilationCompleteKiller() : Promise.resolve();
func = runonCompilationComplete;
break;
case 'run-on-first-success-command':
promise = firstSuccessKiller ? firstSuccessKiller() : Promise.resolve();
func = runOnFirstSuccessCommand;
break;
case 'run-on-failure-command':
promise = failureKiller ? failureKiller() : Promise.resolve();
func = runOnFailureCommand;
break;
case 'run-on-success-command':
promise = successKiller ? successKiller() : Promise.resolve();
func = runOnSuccessCommand;
break;
default:
console.log('Unknown message', msg);
}
if (func) {
promise.then(func);
}
});
}
const Signal = {

@@ -103,0 +154,0 @@ send: typeof process.send === 'function' ? (...e) => process.send(...e) : () => {},

2

package.json
{
"name": "tsc-watch",
"version": "4.3.1",
"version": "4.4.0",
"description": "The TypeScript compiler with onSuccess command",

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

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

### From Code
### From npm script
```
"dev-server": "tsc-watch --noClear -p ./src/tsconfig.json --onSuccess \"node ./dist/server.js\"",
```
### From javacript
You can see a detailed example [here](https://github.com/gilamran/tsc-watch/blob/master/tsc-watch-client-example.js)
The client is implemented as an instance of `Node.JS`'s `EventEmitter`, with the following events:

@@ -54,0 +61,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc