1 #!/usr/bin/env node
2
3 import os from "os"
4 import util from "util"
5 import createCli from "./create-cli"
6
7 const useJsonLogger = process.argv.slice(2).some((arg) => arg.includes(`json`))
8
9 if (useJsonLogger) {
10 process.env.GATSBY_LOGGER = `json`
11 }
12
13 // Ensure stable runs on Windows when started from different shells (i.e. c:\dir vs C:\dir)
14 if (os.platform() === `win32`) {
15 // ensureWindowsDriveLetterIsUppercase()
16 }
17
18 process.on(`unhandledRejection`, (reason) => {
19 // This will exit the process in newer Node anyway so lets be consistent
20 // across versions and crash
21
22 // reason can be anything, it can be a message, an object, ANYTHING!
23 // we convert it to an error object, so we don't crash on structured error validation
24 if (!(reason instanceof Error)) {
25 reason = new Error(util.format(reason))
26 }
27
28 console.log(reason)
29 // report.panic(`UNHANDLED REJECTION`, reason as Error)
30 })
31
32 process.on(`uncaughtException`, (error) => {
33 console.log(error)
34 // report.panic(`UNHANDLED EXCEPTION`, error)
35 })
36
37 createCli(process.argv)