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
172
172
config . i18n = i18nConfig
173
173
174
174
// 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
+ ) {
176
180
let defaultJobsCollection = getDefaultJobsCollection ( config as unknown as Config )
177
181
178
182
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
13
13
const workflowSlugs : Set < string > = new Set ( )
14
14
const taskSlugs : Set < string > = new Set ( [ 'inline' ] )
15
15
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
+ }
19
21
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
+ }
28
32
29
33
const jobsCollection : CollectionConfig = {
30
34
slug : 'payload-jobs' ,
You can’t perform that action at this time.
0 commit comments