Allow to add identifiers
This release adds the possibility to define identifier
.
The identifier is a string that prefix the environment variable value and let you customize the value resolution.
import { readFile } from 'node:fs/promises'
import { EnvParser } from '@adonisjs/env'
EnvParser.identifier('file', (value) => {
return readFile(value, 'utf-8')
})
const envParser = new EnvParser(`
DB_PASSWORD=file:/run/secret/db_password
`)
console.log(await envParser.parse()) // { DB_PASSWORD: 'Value from file /run/secret/db_password' }
Breaking
The parse
method of the EnvParser
class is now async.