Skip to content

Commit

Permalink
doc and test
Browse files Browse the repository at this point in the history
  • Loading branch information
llllvvuu committed Mar 27, 2024
1 parent 56d3b97 commit ca8d2f0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib/stdout-manipulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +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`.',
' --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
16 changes: 16 additions & 0 deletions src/test/args-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,22 @@ describe('Args Manager', () => {
).toBe('COMMAND_TO_RUN');
});

it('Should return the onEmit', () => {
expect(extractArgs(['node', 'tsc-watch.js', '1.ts']).onEmitCommand).toBe(null);
expect(
extractArgs(['node', 'tsc-watch.js', '--onEmit', 'COMMAND_TO_RUN', '1.ts'])
.onEmitCommand,
).toBe('COMMAND_TO_RUN');
});

it('Should return the onEmitDebounceMs', () => {
expect(extractArgs(['node', 'tsc-watch.js', '1.ts']).onEmitDebounceMs).toBe(300);
expect(
extractArgs(['node', 'tsc-watch.js', '--onEmitDebounceMs', '200', '1.ts'])
.onEmitDebounceMs,
).toBe(200);
});

it('Should return the onCompilationComplete', () => {
expect(extractArgs(['node', 'tsc-watch.js', '1.ts']).onCompilationComplete).toBe(null);
expect(
Expand Down

0 comments on commit ca8d2f0

Please sign in to comment.