Factor out `getEnvironment` function in build script (#9114)

There are no functional changes. This was extracted from #8170
feature/default_network_editable
Mark Stacey 4 years ago
parent 7ab01c8ffd
commit d4c3fa6885
  1. 37
      development/build/scripts.js

@ -316,23 +316,7 @@ function createScriptTasks ({ browserPlatforms, livereload }) {
bundler = bundler.external(opts.externalDependencies) bundler = bundler.external(opts.externalDependencies)
} }
let environment const environment = getEnvironment({ devMode: opts.devMode, test: opts.testing })
if (opts.devMode) {
environment = 'development'
} else if (opts.testing) {
environment = 'testing'
} else if (process.env.CIRCLE_BRANCH === 'master') {
environment = 'production'
} else if (/^Version-v(\d+)[.](\d+)[.](\d+)/.test(process.env.CIRCLE_BRANCH)) {
environment = 'release-candidate'
} else if (process.env.CIRCLE_BRANCH === 'develop') {
environment = 'staging'
} else if (process.env.CIRCLE_PULL_REQUEST) {
environment = 'pull-request'
} else {
environment = 'other'
}
if (environment === 'production' && !process.env.SENTRY_DSN) { if (environment === 'production' && !process.env.SENTRY_DSN) {
throw new Error('Missing SENTRY_DSN environment variable') throw new Error('Missing SENTRY_DSN environment variable')
} }
@ -372,3 +356,22 @@ function createScriptTasks ({ browserPlatforms, livereload }) {
function beep () { function beep () {
process.stdout.write('\x07') process.stdout.write('\x07')
} }
function getEnvironment ({ devMode, test }) {
// get environment slug
if (devMode) {
return 'development'
} else if (test) {
return 'testing'
} else if (process.env.CIRCLE_BRANCH === 'master') {
return 'production'
} else if (/^Version-v(\d+)[.](\d+)[.](\d+)/.test(process.env.CIRCLE_BRANCH)) {
return 'release-candidate'
} else if (process.env.CIRCLE_BRANCH === 'develop') {
return 'staging'
} else if (process.env.CIRCLE_PULL_REQUEST) {
return 'pull-request'
} else {
return 'other'
}
}

Loading…
Cancel
Save