Sha256: 20d658b01f6e93a6861af1bbec2fff9193345016ada804caf6d0a2ec63fa8b67

Contents?: true

Size: 642 Bytes

Versions: 29

Compression:

Stored size: 642 Bytes

Contents

const { safeLoad } = require('js-yaml')
const { readFileSync } = require('fs')

const NODE_ENVIRONMENTS = ['development', 'production', 'test']
const DEFAULT = 'production'
const configPath = require('./configPath')

const railsEnv = process.env.RAILS_ENV
const nodeEnv = process.env.NODE_ENV

const config = safeLoad(readFileSync(configPath), 'utf8')
const availableEnvironments = Object.keys(config).join('|')
const regex = new RegExp(`^(${availableEnvironments})$`, 'g')

module.exports = {
  railsEnv: railsEnv && railsEnv.match(regex) ? railsEnv : DEFAULT,
  nodeEnv: nodeEnv && NODE_ENVIRONMENTS.includes(nodeEnv) ? nodeEnv : DEFAULT
}

Version data entries

29 entries across 29 versions & 7 rubygems

Version Path
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/@rails/webpacker/package/env.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/@rails/webpacker/package/env.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/@rails/webpacker/package/env.js
jetpacker-0.5.0 package/env.js
tang-0.2.0 spec/tang_app/node_modules/@rails/webpacker/package/env.js
tang-0.1.0 spec/tang_app/node_modules/@rails/webpacker/package/env.js
tang-0.0.9 spec/tang_app/node_modules/@rails/webpacker/package/env.js
webpacker-5.2.1 package/env.js
webpacker-5.2.0 package/env.js