https://github.com/featurist/shellsubstitute
https://github.com/featurist/shellsubstitute
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/featurist/shellsubstitute
- Owner: featurist
- Created: 2014-10-20T12:47:00.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-10-18T09:02:20.000Z (over 8 years ago)
- Last Synced: 2024-11-11T19:11:42.245Z (6 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 4
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Shell Substitute [](https://www.npmjs.com/package/shellsubstitute) [](https://www.npmjs.com/package/shellsubstitute) [](https://travis-ci.org/featurist/shellsubstitute)
Like shell substitution but for your JS.
var substitute = require('shellsubstitute');
substitute('Hi $USER', {USER: 'Josh'}) // Hi Josh
substitute('Hi ${USER}', {USER: 'Josh'}) // Hi Josh// escape
substitute('Hi \\$USER', {USER: 'Josh'}) // Hi $USER
substitute('Hi \\${USER}', {USER: 'Josh'}) // Hi ${USER}// escape escapes
substitute('Hi \\\\$USER', {USER: 'Josh'}) // Hi \$USER
substitute('Hi \\\\${USER}', {USER: 'Josh'}) // Hi \${USER}## Syntax
Variables are `$` followed by `_` or numbers `0-9` or upper or lower-case characters `a-z`.
Variables can be wrapped in braces `{...}`. Useful to delimit the variable from following text.