Simplify prebuild check workflow

This commit is contained in:
Ben Edgington
2022-06-23 12:18:22 +01:00
parent c93f767cbc
commit 368bd223fb
4 changed files with 14 additions and 20 deletions

View File

@@ -1,16 +0,0 @@
// Run the pre-build script standalone to check for issues without doiing a full build
const doPreBuild = require('./prebuild')
const reporter = {
// Cheat sheets for colours:
// - https://tintin.mudhalla.net/info/xterm/
// - https://tintin.mudhalla.net/info/256color/
info: function (m) { console.log('\x1b[38;5;19m%s\x1b[0m %s', 'info', m) },
warn: function (m) { console.log('\x1b[38;5;130m%s\x1b[0m %s', 'warn', m) },
error: function (m) { console.log('\x1b[38;5;160m%s\x1b[0m %s', 'error', m) },
success: function (m) { console.log('\x1b[38;5;34m%s\x1b[0m %s', 'success', m) },
}
doPreBuild(reporter)

View File

@@ -17,7 +17,17 @@ const doSplitLint = true
const sourceMarkdown = 'src/book.md'
const splitMarkdown = glob.sync('src/md/**/*.md', {'ignore': 'src/md/annotated.md'})
module.exports = (reporter) => {
module.exports.runChecks = (reporter) => {
if (!reporter) {
reporter = {
// https://tintin.mudhalla.net/info/xterm/
// https://tintin.mudhalla.net/info/256color/
info: function (m) { console.log('\x1b[38;5;19m%s\x1b[0m %s', 'info', m) },
warn: function (m) { console.log('\x1b[38;5;130m%s\x1b[0m %s', 'warn', m) },
error: function (m) { console.log('\x1b[38;5;160m%s\x1b[0m %s', 'error', m) },
}
}
var sourceLintSucceeded = true

View File

@@ -1,11 +1,11 @@
const path = require('path')
const doPreBuild = require('./bin/build/prebuild')
const prebuild = require('./bin/build/prebuild')
// Set up a hook to pre-process the source file into split files, and perform various
// checking and linting operations prior to building.
exports.onPreInit = ({ reporter }) => {
try {
doPreBuild(reporter)
prebuild.runChecks(reporter)
} catch (err) {
reporter.panicOnBuild('Could not run pre-build tasks,', err)
}

View File

@@ -11,7 +11,7 @@
"build": "gatsby build --prefix-paths",
"serve": "gatsby serve --prefix-paths",
"clean": "gatsby clean",
"check": "node ./bin/build/check.js"
"check": "node -e 'require(\"./bin/build/prebuild\").runChecks()'"
},
"dependencies": {
"gatsby": "^4.17.0",