Comparing version 1.1.37 to 2.0.0
# @gilamran/tsc-watch CHANGELOG | ||
## v2.0.0 - 12/2/2019 | ||
As many users requested, from now on `--onFirstSuccess` process will not get killed, only when tsc-watch is killed. (Based on @amir-arad's PR) | ||
This version fixes Issue #20, #21 and #50. | ||
## v1.1.37 - 8/2/2019 | ||
@@ -4,0 +9,0 @@ |
setInterval(() => console.log(Math.random()), 1000); |
setInterval(() => console.log(Math.random()), 1000); |
@@ -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 stripAnsi = require('strip-ansi'); |
#!/usr/bin/env node | ||
'use strict'; | ||
const killer = require('./killer'); | ||
const nodeCleanup = require('node-cleanup'); | ||
const spawn = require('cross-spawn'); | ||
const stringArgv = require('string-argv'); | ||
const run = require('./runner'); | ||
const { extractArgs } = require('./args-manager'); | ||
@@ -13,51 +12,19 @@ const { manipulate, detectState, isClear, print } = require('./stdout-manipulator'); | ||
let firstTime = true; | ||
let firstSuccessProcess = null; | ||
let firstSuccessProcessExited = null; | ||
let successProcess = null; | ||
let successProcessExited = null; | ||
let failureProcess = null; | ||
let failureProcessExited = null; | ||
let { onFirstSuccessCommand, onSuccessCommand, onFailureCommand, noColors, noClear, compiler, args } = extractArgs(process.argv); | ||
function runCommand(fullCommand) { | ||
if (fullCommand) { | ||
const parts = stringArgv(fullCommand); | ||
const exec = parts[0]; | ||
const args = parts.splice(1); | ||
return spawn(exec, args, { | ||
stdio: 'inherit', | ||
}); | ||
} | ||
} | ||
let firstSuccessKiller = null; | ||
let successKiller = null; | ||
let failureKiller = null; | ||
function killAllProcesses() { | ||
return Promise.all([killAllSuccessProcesses(), killFailureProcess()]); | ||
} | ||
let { onFirstSuccessCommand, onSuccessCommand, onFailureCommand, noColors, noClear, compiler, args } = extractArgs( | ||
process.argv, | ||
); | ||
function killAllSuccessProcesses() { | ||
const promises = []; | ||
if (firstSuccessProcess) { | ||
promises.push(killer(firstSuccessProcess).then(() => (firstSuccessProcess = null))); | ||
promises.push(firstSuccessProcessExited.then(() => (firstSuccessProcessExited = null))); | ||
} | ||
if (successProcess) { | ||
promises.push(killer(successProcess).then(() => (successProcess = null))); | ||
promises.push(successProcessExited.then(() => (successProcessExited = null))); | ||
} | ||
return Promise.all(promises); | ||
function killProcesses(killAll) { | ||
return Promise.all([ | ||
killAll && firstSuccessKiller ? firstSuccessKiller() : null, | ||
successKiller ? successKiller() : null, | ||
failureKiller ? failureKiller() : null, | ||
]); | ||
} | ||
function killFailureProcess() { | ||
const promises = []; | ||
if (failureProcess) { | ||
promises.push(killer(failureProcess).then(() => (failureProcess = null))); | ||
promises.push(failureProcessExited.then(() => (failureProcessExited = null))); | ||
} | ||
return Promise.all(promises); | ||
} | ||
let bin; | ||
@@ -85,8 +52,7 @@ try { | ||
if (compilationComplete) { | ||
killAllProcesses().then(() => { | ||
killProcesses(false).then(() => { | ||
if (compilationError) { | ||
Signal.emitFail(); | ||
if (onFailureCommand) { | ||
failureProcess = runCommand(onFailureCommand); | ||
failureProcessExited = new Promise(resolve => failureProcess.on('exit', resolve)); | ||
failureKiller = run(onFailureCommand); | ||
} | ||
@@ -97,7 +63,5 @@ } else { | ||
firstTime = false; | ||
firstSuccessProcess = runCommand(onFirstSuccessCommand); | ||
firstSuccessProcessExited = new Promise(resolve => firstSuccessProcess.on('exit', resolve)); | ||
firstSuccessKiller = run(onFirstSuccessCommand); | ||
} else if (onSuccessCommand) { | ||
successProcess = runCommand(onSuccessCommand); | ||
successProcessExited = new Promise(resolve => successProcess.on('exit', resolve)); | ||
successKiller = run(onSuccessCommand); | ||
} | ||
@@ -121,4 +85,4 @@ } | ||
nodeCleanup((_exitCode, signal) => { | ||
killAllProcesses(); | ||
killProcesses(true); | ||
tscProcess.kill(signal); | ||
}); |
{ | ||
"name": "tsc-watch", | ||
"version": "1.1.37", | ||
"version": "2.0.0", | ||
"description": "The TypeScript compiler with onSuccess command", | ||
@@ -29,3 +29,3 @@ "scripts": { | ||
"singleQuote": true, | ||
"printWidth": 240 | ||
"printWidth": 120 | ||
}, | ||
@@ -32,0 +32,0 @@ "dependencies": { |
@@ -12,2 +12,4 @@ # The TypeScript compiler with `--onSuccess` argument | ||
All above `COMMAND`s will be killed on process exit | ||
## Install | ||
@@ -14,0 +16,0 @@ |
@@ -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 { expect } = require('chai'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22
77
23421
452