Skip to content

Commit

Permalink
fix(watch): dont log rerunning on first run
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber committed Nov 23, 2023
1 parent fb61588 commit 5a71a87
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
25 changes: 14 additions & 11 deletions src/watch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,21 @@ export const watchCommand = command({
return;
}

// If running process
if (runProcess?.exitCode === null) {
log('restarting');
waitingExits = true;
await killProcess(runProcess);
waitingExits = false;
} else {
log('rerunning');
}
// If not first run
if (runProcess) {
// If process still running
if (runProcess.exitCode === null) {
log('restarting');
waitingExits = true;
await killProcess(runProcess);
waitingExits = false;
} else {
log('rerunning');
}

if (options.clearScreen) {
process.stdout.write(clearScreen);
if (options.clearScreen) {
process.stdout.write(clearScreen);
}
}

runProcess = spawnProcess();
Expand Down
4 changes: 3 additions & 1 deletion tests/specs/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export default testSuite(async ({ describe }) => {

tsxProcess.kill();

await tsxProcess;
const { all } = await tsxProcess;
expect(all!.startsWith('hello world\n')).toBe(true);
}, 10_000);

test('suppresses warnings & clear screen', async () => {
Expand Down Expand Up @@ -100,6 +101,7 @@ export default testSuite(async ({ describe }) => {
const { all } = await tsxProcess;
expect(all).not.toMatch('Warning');
expect(all).toMatch('\u001Bc');
expect(all!.startsWith('["')).toBeTruthy();
}, 10_000);

test('passes flags', async () => {
Expand Down

0 comments on commit 5a71a87

Please sign in to comment.