diff --git a/bin/build-checks.js b/bin/build-checks.js new file mode 100755 index 00000000000..0541da3f5a1 --- /dev/null +++ b/bin/build-checks.js @@ -0,0 +1,16 @@ +#!/usr/bin/env node +/* eslint-disable global-require, no-console */ + +const chalk = require('chalk'); + +require('babel-register'); +const config = require('config'); + +const appName = config.get('appName'); + +// Bail if appName isn't set unless explicitly enabled. +if (!appName && process.env.ADDONS_FRONTEND_BUILD_ALL !== '1') { + console.log( + chalk.red('Please specify the appName with NODE_APP_INSTANCE')); + process.exit(1); +} diff --git a/bin/server.js b/bin/server.js index 760b931b8bf..95c08a8a46a 100644 --- a/bin/server.js +++ b/bin/server.js @@ -1,9 +1,19 @@ #!/usr/bin/env node -/* eslint-disable global-require */ +/* eslint-disable global-require, no-console */ + +const chalk = require('chalk'); require('babel-register'); const config = require('config'); +const appName = config.get('appName'); + +if (!appName) { + console.log( + chalk.red('Please specify the appName with NODE_APP_INSTANCE')); + process.exit(1); +} + if (config.util.getEnv('NODE_ENV') === 'development') { if (!require('piping')({ hook: true, diff --git a/package.json b/package.json index d9f9fd1708f..5521cf60788 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "private": true, "scripts": { - "build": "better-npm-run build", + "build": "bin/build-checks.js && better-npm-run build", "extract-locales": "better-npm-run extract-locales", "build:disco": "better-npm-run build:disco", "build:search": "better-npm-run build:search", @@ -15,7 +15,7 @@ "eslint": "eslint .", "stylelint": "stylelint --syntax scss **/*.scss", "lint": "npm run eslint && npm run stylelint", - "servertest": "npm run build && better-npm-run servertest", + "servertest": "ADDONS_FRONTEND_BUILD_ALL=1 npm run build && better-npm-run servertest", "start": "npm run version-check && NODE_PATH='./:./src' node bin/server.js", "start:disco": "NODE_APP_INSTANCE=disco npm start", "start:search": "NODE_APP_INSTANCE=search npm start",