https://github.com/nicomt/varsubst
Simple library to substitute variables into strings
https://github.com/nicomt/varsubst
envsubst substitution variables
Last synced: 3 months ago
JSON representation
Simple library to substitute variables into strings
- Host: GitHub
- URL: https://github.com/nicomt/varsubst
- Owner: nicomt
- Created: 2020-10-19T00:25:38.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-11-10T04:08:06.000Z (7 months ago)
- Last Synced: 2025-11-10T06:07:22.058Z (7 months ago)
- Topics: envsubst, substitution, variables
- Language: JavaScript
- Homepage:
- Size: 21.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# varsubst
> Simple library to substitute variables into strings
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install varsubst
```
## Usage
The API is simple
```js
const varsubst = require('varsubst')
varsubst('hello $var', { var: 'world' }) // hello world
varsubst('inThe${var}OfText', { var: 'Middle' }) // inTheMiddleOfText
varsubst('escaping $${var}', { var: 'noop' }) // escaping ${var}
varsubst('using ${var:-default}', {}) // using default
varsubst('using ${none:-$var} vars', {var: 'nested'}) // using nested vars
varsubst('${USER} is substituting env', process.env) // is substituting env
```