Skip to content

Commit

Permalink
fix: identify that trigger is persistent
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Mar 20, 2023
1 parent 378cc96 commit 0b0b4a8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/subscribe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const defaultTrigger = {
name: 'foo',
onChange: async () => {},
onTeardown: async () => {},
persistent: false,
relativePath: 'foo',
retry: {
retries: 0,
Expand Down
6 changes: 6 additions & 0 deletions src/subscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ export const subscribe = (trigger: Trigger): Subscription => {

activeTask = null;
} else {
if (trigger.persistent) {
log.warn('ignoring event because the trigger is persistent');

return undefined;
}

log.warn(
'waiting for %s (%s) task to complete',
trigger.name,
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export type Trigger = {
name: string;
onChange: OnChangeEventHandler;
onTeardown?: OnTeardownEventHandler;
persistent: boolean;
retry: Retry;
throttleOutput: Throttle;
};
Expand Down
1 change: 1 addition & 0 deletions src/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const watch = (
name: trigger.name,
onChange: trigger.onChange,
onTeardown: trigger.onTeardown,
persistent: trigger.persistent ?? false,
retry: trigger.retry ?? {
retries: 0,
},
Expand Down

0 comments on commit 0b0b4a8

Please sign in to comment.