-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ts): migrate remove-stale-jobs to typescript
- Loading branch information
1 parent
bb38afd
commit a776285
Showing
5 changed files
with
50 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { | ||
IGatsbyState, | ||
IRemoveStaleJobAction, | ||
IGatsbyJobV2, | ||
} from "../redux/types" | ||
|
||
import { isJobStale } from "../utils/jobs-manager" | ||
import { publicActions, internalActions } from "../redux/actions" | ||
|
||
export const removeStaleJobs = ( | ||
state: IGatsbyState | ||
): IRemoveStaleJobAction[] => { | ||
const actions: IRemoveStaleJobAction[] = [] | ||
|
||
// If any of our finished jobs are stale we remove them to keep our cache small | ||
state.jobsV2.complete.forEach( | ||
(job: IGatsbyJobV2, contentDigest: string): void => { | ||
if (isJobStale(job)) { | ||
actions.push(internalActions.removeStaleJob(contentDigest)) | ||
} | ||
} | ||
) | ||
|
||
// If any of our pending jobs do not have an existing inputPath or the inputPath changed | ||
// we remove it from the queue as they would fail anyway | ||
state.jobsV2.incomplete.forEach(({ job, plugin }: IGatsbyJobV2): void => { | ||
if (isJobStale(job)) { | ||
actions.push(internalActions.removeStaleJob(job.contentDigest)) | ||
} else { | ||
actions.push(publicActions.createJobV2(job, plugin)) | ||
} | ||
}) | ||
|
||
return actions | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters