(filepath)
| 1 | const canonicalEnvFilename = require('../helpers/canonicalEnvFilename') |
| 2 | |
| 3 | function 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 | |
| 27 | module.exports = environment |
no test coverage detected
searching dependent graphs…