Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
llllvvuu committed Mar 27, 2024
1 parent 11b89b2 commit 2a86a37
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
| --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--onSuccess COMMAND` | Executes `COMMAND` on **every successful** compilation. |
| `--onFirstSuccess COMMAND` | Executes `COMMAND` on the **first successful** compilation. |
| `--onEmit COMMAND` | Executes debounced `COMMAND` on **every emitted file**. |
| `--onEmitDebounceMs DELAY` | Delay by which to debounce `--onEmit`. |
| `--onEmit COMMAND` | Executes debounced `COMMAND` on **every emitted file**, ignoring unchanged inputs and regardless of success or failure. |
| `--onEmitDebounceMs DELAY` | Delay by which to debounce `--onEmit` (default: 300). |
| `--onFailure COMMAND` | Executes `COMMAND` on **every failed** compilation. |
| `--onCompilationStarted COMMAND` | Executes `COMMAND` on **every compilation start** event (initial and incremental). |
| `--onCompilationComplete COMMAND` | Executes `COMMAND` on **every successful or failed** compilation. |
Expand Down Expand Up @@ -122,5 +122,7 @@ Notes:
- The (`onSuccess`) `COMMAND` will not run if the compilation failed.
- The (`onEmit`) `COMMAND` will not run if the compilation succeeded with no changed files, unless it is the first success.
- The (`onEmit`) `COMMAND` will run if the compilation failed, but still emitted changed files.
- The (`onEmit`) `COMMAND` will not run 100 times for 100 files, due to `--onEmitDebounce`
- The (`onEmit`) `COMMAND` will not cancel the `onSuccess`/`onFirstSuccess`/`onFailure`/`onCompilationComplete`/`onCompilationStarted` commands and vice versa.
- `tsc-watch` is using the currently installed TypeScript compiler.
- `tsc-watch` is not changing the compiler, just adds the new arguments, compilation is the same, and all other arguments are the same.
4 changes: 2 additions & 2 deletions src/lib/stdout-manipulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const newAdditionToSyntax = [
' --onSuccess COMMAND Executes `COMMAND` on **every successful** compilation.',
' --onFirstSuccess COMMAND Executes `COMMAND` on the **first successful** compilation.',
' --onFailure COMMAND Executes `COMMAND` on **every failed** compilation.',
' --onEmit COMMAND Executes debounced `COMMAND` on **every emitted file**.',
' --onEmitDebounceMs DELAY Delay by which to debounce `--onEmit`.',
' --onEmit COMMAND Executes debounced `COMMAND` on **every emitted file**, ignoring unchanged inputs and regardless of success or failure.',
' --onEmitDebounceMs DELAY Delay by which to debounce `--onEmit` (default: 300).',
' --onCompilationStarted COMMAND Executes `COMMAND` on **every compilation start** event.',
' --onCompilationComplete COMMAND Executes `COMMAND` on **every successful or failed** compilation.',
' --noColors Removes the red/green colors from the compiler output',
Expand Down
8 changes: 4 additions & 4 deletions src/lib/tsc-watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,20 @@ function killProcesses(currentCompilationId: number, killAll: boolean): Promise<
return runningKillProcessesPromise;
}

// We separate this from `runningKillProcessesPromise` to avoid canceling each other
let runningKillEmitProcessesPromise: Promise<number> | null = null;
function killEmitProcesses(currentEmitId: number): Promise<number> {
if (runningKillEmitProcessesPromise) {
return runningKillEmitProcessesPromise.then(() => currentEmitId);
}

const promisesToWaitFor: Promise<any>[] = [];

let emitKilled = Promise.resolve();
if (emitKiller) {
promisesToWaitFor.push(emitKiller());
emitKilled = emitKiller();
emitKiller = null;
}

runningKillEmitProcessesPromise = Promise.all(promisesToWaitFor).then(() => {
runningKillEmitProcessesPromise = emitKilled.then(() => {
runningKillEmitProcessesPromise = null;
return currentEmitId;
});
Expand Down

0 comments on commit 2a86a37

Please sign in to comment.