Skip to content

Commit

Permalink
Factor out getEnvironment function in build script (#9114)
Browse files Browse the repository at this point in the history
There are no functional changes. This was extracted from #8170
  • Loading branch information
Gudahtt committed Aug 7, 2020
1 parent 7ab01c8 commit d4c3fa6
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions development/build/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,23 +316,7 @@ function createScriptTasks ({ browserPlatforms, livereload }) {
bundler = bundler.external(opts.externalDependencies)
}

let environment
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'
}

const environment = getEnvironment({ devMode: opts.devMode, test: opts.testing })
if (environment === 'production' && !process.env.SENTRY_DSN) {
throw new Error('Missing SENTRY_DSN environment variable')
}
Expand Down Expand Up @@ -372,3 +356,22 @@ function createScriptTasks ({ browserPlatforms, livereload }) {
function beep () {
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'
}
}

0 comments on commit d4c3fa6

Please sign in to comment.