mithril-vndb/scripts/_command.js
Isiah Meadows 22e6d37a26 Refactor the scripts to work as advertised
- Correct docs generation to always fetch its dependency
- Don't try to close a handle that's already been closed by other methods
- Allow the release script to actually be testable.
2019-08-17 21:58:57 -04:00

35 lines
743 B
JavaScript

"use strict"
process.on("unhandledRejection", function (e) {
process.exitCode = 1
if (!e.stdout || !e.stderr) return false
console.error(e.stack)
if (e.stdout && e.stdout.length) {
console.error(e.stdout.toString("utf-8"))
}
if (e.stderr && e.stderr.length) {
console.error(e.stderr.toString("utf-8"))
}
return true
})
module.exports = ({exec, watch}) => {
const index = process.argv.indexOf("--watch")
if (index >= 0) {
process.argv.splice(index, 1)
if (watch == null) {
console.error("Watching this script is not supported!")
// eslint-disable-next-line no-process-exit
process.exit(1)
}
watch()
} else {
Promise.resolve(exec()).then((code) => {
if (code != null) process.exitCode = code
})
}
}