diff --git a/bin/build/check.js b/bin/build/check.js deleted file mode 100644 index 5d9ad88..0000000 --- a/bin/build/check.js +++ /dev/null @@ -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) diff --git a/bin/build/prebuild.js b/bin/build/prebuild.js index 194aa15..af1825d 100644 --- a/bin/build/prebuild.js +++ b/bin/build/prebuild.js @@ -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 diff --git a/gatsby-node.js b/gatsby-node.js index c36295e..0b59a63 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -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) } diff --git a/package.json b/package.json index a5f62a7..d4d94b4 100644 --- a/package.json +++ b/package.json @@ -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",