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
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/webpacker-5.4.4/package/env.js
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/webpacker-5.4.4/package/env.js
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/webpacker-5.4.4/package/env.js
jetpacker-0.7.0 package/env.js
webpacker-5.4.4 package/env.js
jetpacker-0.6.0 package/env.js
disco_app-0.16.1 test/dummy/node_modules/@rails/webpacker/package/env.js
disco_app-0.15.2 test/dummy/node_modules/@rails/webpacker/package/env.js
disco_app-0.18.4 test/dummy/node_modules/@rails/webpacker/package/env.js
disco_app-0.18.1 test/dummy/node_modules/@rails/webpacker/package/env.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/@rails/webpacker/package/env.js
disco_app-0.14.0 test/dummy/node_modules/@rails/webpacker/package/env.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/@rails/webpacker/package/env.js
webpacker-5.4.3 package/env.js
webpacker-5.4.2 package/env.js
webpacker-5.4.1 package/env.js
webpacker-5.4.0 package/env.js
webpacker-5.3.0 package/env.js
webpacker-5.2.2 package/env.js
tang-0.2.1 spec/tang_app/node_modules/@rails/webpacker/package/env.js