@@ -23,6 +23,7 @@ import { detectLmdbStore } from "../datastore"
23
23
import { loadConfig } from "../bootstrap/load-config"
24
24
import { loadPlugins } from "../bootstrap/load-plugins"
25
25
import type { InternalJob } from "../utils/jobs/types"
26
+ import type { IDataLayerContext } from "./../state-machines/data-layer/types"
26
27
import { enableNodeMutationsDetection } from "../utils/detect-node-mutations"
27
28
import { compileGatsbyFiles } from "../utils/parcel/compile-gatsby-files"
28
29
import { resolveModule } from "../utils/module-resolver"
@@ -74,12 +75,15 @@ process.on(`unhandledRejection`, (reason: unknown) => {
74
75
// Otherwise leave commented out.
75
76
// require(`../bootstrap/log-line-function`)
76
77
78
+ type WebhookBody = IDataLayerContext [ "webhookBody" ]
79
+
77
80
export async function initialize ( {
78
81
program : args ,
79
82
parentSpan,
80
83
} : IBuildContext ) : Promise < {
81
84
store : Store < IGatsbyState , AnyAction >
82
85
workerPool : WorkerPool . GatsbyWorkerPool
86
+ webhookBody ?: WebhookBody
83
87
} > {
84
88
if ( process . env . GATSBY_DISABLE_CACHE_PERSISTENCE ) {
85
89
reporter . info (
@@ -663,8 +667,21 @@ export async function initialize({
663
667
}
664
668
}
665
669
670
+ let initialWebhookBody : WebhookBody = undefined
671
+
672
+ if ( process . env . GATSBY_INITIAL_WEBHOOK_BODY ) {
673
+ try {
674
+ initialWebhookBody = JSON . parse ( process . env . GATSBY_INITIAL_WEBHOOK_BODY )
675
+ } catch ( e ) {
676
+ reporter . error (
677
+ `Failed to parse GATSBY_INITIAL_WEBHOOK_BODY as JSON:\n"${ e . message } "`
678
+ )
679
+ }
680
+ }
681
+
666
682
return {
667
683
store,
668
684
workerPool,
685
+ webhookBody : initialWebhookBody ,
669
686
}
670
687
}
0 commit comments