0.3.0 • Published 3 years ago
@zero-version/prep-config-file v0.3.0
prep-config-file
Replace placeholders in a config file with corresponding environment variable values
Install
npm install @zero-version/prep-config-file --save-dev
Usage
Assume you have the file ./config/ecosystem.config.js:
module.exports = {
apps: [
env: {
DB_RO_USER: 'read-only-user',
DB_RO_PASSWORD: '${DB_RO_PASSWORD}',
DB_RW_USER: 'read-write-user',
DB_RW_PASSWORD: '${DB_RW_PASSWORD}',
DB_SERVER: 'MY_SERVER',
DB_PORT: '1433',
DB_DATABASE: 'master',
}
]
}
If you set DB_RO_PASSWORD='ro_p@$$w0rd?'
and DB_RW_PASSWORD='rw_p@$$w0rd?'
, running the command npx prep-config-file ./.config/ecosystem.config.js ./ecosystem.config.js
, will produce the file ./ecosystem.config.js:
module.exports = {
apps: [
{
env: {
DB_RO_USER: 'read-only-user',
DB_RO_PASSWORD: 'ro_p@$$w0rd?',
DB_RW_USER: 'read-write-user',
DB_RW_PASSWORD: 'rw_p@$$w0rd?',
DB_SERVER: 'MY_SERVER',
DB_PORT: '1433',
DB_DATABASE: 'master',
},
},
],
};
Run npx prep-config-file --help
for more options.