feat: throw errors during startup if NODE_ENV is production and the application is not in a usable state (#1046)

This commit is contained in:
Eric Stern 2019-10-23 12:21:53 -07:00 committed by Gregor Martynus
parent 65382de391
commit ca3d2f8a58
1 changed files with 13 additions and 0 deletions

View File

@ -72,6 +72,19 @@ export class Probot {
const options = readOptions()
const probot = new Probot(options)
if (!options.id || !options.cert) {
if (process.env.NODE_ENV === 'production') {
if (!options.id) {
throw new Error(
'Application ID is missing, and is required to run in production mode. ' +
'To resolve, ensure the APP_ID environment variable is set.'
)
} else if (!options.cert) {
throw new Error(
'Certificate is missing, and is required to run in production mode. ' +
'To resolve, ensure either the PRIVATE_KEY or PRIVATE_KEY_PATH environment variable is set and contains a valid certificate'
)
}
}
probot.load(setupApp)
} else if (Array.isArray(appFn)) {
const pkg = await pkgConf('probot')