Skip to content

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

Notifications You must be signed in to change notification settings

mekomsolutions/env-substitution

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Resources

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •