File tree Expand file tree Collapse file tree 2 files changed +20
-12
lines changed
Expand file tree Collapse file tree 2 files changed +20
-12
lines changed Original file line number Diff line number Diff line change @@ -172,7 +172,11 @@ export const sanitizeConfig = async (incomingConfig: Config): Promise<SanitizedC
172172 config . i18n = i18nConfig
173173
174174 // Need to add default jobs collection before locked documents collections
175- if ( Array . isArray ( configWithDefaults . jobs ?. tasks ) && configWithDefaults . jobs . tasks . length > 0 ) {
175+ if (
176+ ( Array . isArray ( configWithDefaults . jobs ?. tasks ) && configWithDefaults . jobs ?. tasks ?. length ) ||
177+ ( Array . isArray ( configWithDefaults . jobs ?. workflows ) &&
178+ configWithDefaults . jobs ?. workflows ?. length )
179+ ) {
176180 let defaultJobsCollection = getDefaultJobsCollection ( config as unknown as Config )
177181
178182 if ( typeof configWithDefaults . jobs . jobsCollectionOverrides === 'function' ) {
Original file line number Diff line number Diff line change @@ -13,18 +13,22 @@ export const getDefaultJobsCollection: (config: Config) => CollectionConfig | nu
1313 const workflowSlugs : Set < string > = new Set ( )
1414 const taskSlugs : Set < string > = new Set ( [ 'inline' ] )
1515
16- config . jobs ?. workflows . forEach ( ( workflow ) => {
17- workflowSlugs . add ( workflow . slug )
18- } )
16+ if ( config . jobs ?. workflows . length ) {
17+ config . jobs ?. workflows . forEach ( ( workflow ) => {
18+ workflowSlugs . add ( workflow . slug )
19+ } )
20+ }
1921
20- config . jobs . tasks . forEach ( ( task ) => {
21- if ( workflowSlugs . has ( task . slug ) ) {
22- throw new Error (
23- `Task slug "${ task . slug } " is already used by a workflow. No tasks are allowed to have the same slug as a workflow.` ,
24- )
25- }
26- taskSlugs . add ( task . slug )
27- } )
22+ if ( config . jobs ?. tasks . length ) {
23+ config . jobs . tasks . forEach ( ( task ) => {
24+ if ( workflowSlugs . has ( task . slug ) ) {
25+ throw new Error (
26+ `Task slug "${ task . slug } " is already used by a workflow. No tasks are allowed to have the same slug as a workflow.` ,
27+ )
28+ }
29+ taskSlugs . add ( task . slug )
30+ } )
31+ }
2832
2933 const jobsCollection : CollectionConfig = {
3034 slug : 'payload-jobs' ,
You can’t perform that action at this time.
0 commit comments