0.0.1 • Published 2 years ago

@script-box/template-env.cli v0.0.1

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
2 years ago

@script-box/template-env.cli

Replace placeholders in a config file with corresponding environment variable values

Install

npm install @script-box/template-env.cli --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 tenv ./.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 tenv --help for more options.