corneliouzbett / env-substitution

Node JS project to recursively substitute variables in a source folder.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

env-substitution

Simple Node JS js script that will recusively substitute placeholders in the form of ${ENV_VAR} or $ENV_VAR in the folder set in FILE_PATH.

Only files with the extensions as set in allowedExtensions will be taken into account:

const allowedExtensions = ['.json', '.yml', '.yaml', '.csv', '.xml', '.properties', '.txt'];

Quick start

Set the source folder to search in:

$ export FILE_PATH=<path to folder to substitute>

Eg:

├── my_source_folder
│   └── folder1
│       ├── file.txt - "Hello $WORLD"

Export the variables values to be substituted:

$ export ENV_VAR=testenv

Eg:

export WORLD=Uganda!

Run:

$ node cmd.js

All references to ENV_VARare now replaced by testenv

Eg:

├── my_source_folder
│   └── folder1
│       ├── file.txt - "Hello Uganda!"

Locally build Docker image

Though this project is already covered by a GitHub Actions workflow which builds and publishes the Docker image, you can build it locally with the following command:

$ docker build . -t mekomsolutions/env-substitution

About

Node JS project to recursively substitute variables in a source folder.


Languages

Language:Shell 52.9%Language:JavaScript 22.4%Language:HCL 22.1%Language:Dockerfile 2.5%