Skip to content

Commit

Permalink
fix(plugin): add ext.configure event to plugin options schema
Browse files Browse the repository at this point in the history
  • Loading branch information
mohatt committed Mar 9, 2021
1 parent 5224710 commit 9d6d8cd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
19 changes: 8 additions & 11 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ export function schema (joi: GatsbyJoi): GatsbyJoi {
.valid('sequential', 'parallel')
.description('Determines how the files are processed.')
})
const EventTypeSchema = (events: string[]): GatsbyJoi => joi.object()
.pattern(
joi.string().valid(...events),
joi.function().maxArity(1)
)
return joi.object({
enabled: joi.boolean()
.description('Whether to run the postbuild or not.'),
Expand All @@ -64,17 +69,9 @@ export function schema (joi: GatsbyJoi): GatsbyJoi {
ignore: joi.array().items(joi.string())
.description('File paths to exclude from processing.'),
events: joi.object({
on: joi.object().pattern(
joi.string()
.valid('bootstrap', 'postbuild', 'shutdown'),
joi.function()),
html: joi.object().pattern(
joi.string()
.valid('parse', 'tree', 'node', 'serialize', 'write'),
joi.function())
}).pattern(joi.string(), joi.object({
content: joi.function()
}))
on: EventTypeSchema(['bootstrap', 'postbuild', 'shutdown']),
html: EventTypeSchema(['configure', 'parse', 'tree', 'node', 'serialize', 'write'])
}).pattern(joi.string(), EventTypeSchema(['configure', 'content']))
.description('Set of events to added as a custom postbuild task.'),
processing: processingSchema
.description('Default file processing options for all extensions.'),
Expand Down
6 changes: 4 additions & 2 deletions src/postbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,11 @@ export default class Postbuild {
})

// Write the full postbuild report
const reports = this.fs.reporter.getReports()
if (this.options.report) {
await this.fs.create('postbuild.log.json', JSON.stringify(reports, null, 2))
await this.fs.create(
'postbuild.log.json',
JSON.stringify(this.fs.reporter.getReports(), null, 2)
)
}

const saving = this.fs.reporter.getTotalSaved()
Expand Down

0 comments on commit 9d6d8cd

Please # to comment.