MCPcopy
hub / github.com/dotenvx/dotenvx / environment

Function environment

src/lib/conventions/environment.js:3–25  ·  view source on GitHub ↗
(filepath)

Source from the content-addressed store, hash-verified

1const canonicalEnvFilename = require('../helpers/canonicalEnvFilename')
2
3function environment (filepath) {
4 const filename = canonicalEnvFilename(filepath)
5
6 const parts = filename.split('.')
7 const possibleEnvironmentList = [...parts.slice(2)]
8
9 if (possibleEnvironmentList.length === 0) {
10 // handle .env1 -> development1
11 const environment = filename.replace('.env', 'development')
12
13 return environment
14 }
15
16 if (possibleEnvironmentList.length === 1) {
17 return possibleEnvironmentList[0]
18 }
19
20 if (possibleEnvironmentList.length === 2) {
21 return possibleEnvironmentList.join('_')
22 }
23
24 return possibleEnvironmentList.slice(0, 2).join('_')
25}
26
27module.exports = environment

Callers 3

keypairMetadataFunction · 0.85
keynamesFunction · 0.85

Calls 1

canonicalEnvFilenameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…