shellsubstitute

1.2.0 • Public • Published

Shell Substitute npm version npm Build Status

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.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.2.0
    16,670
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.2.0
    16,670
  • 1.1.0
    1
  • 1.0.0
    0

Package Sidebar

Install

npm i shellsubstitute

Weekly Downloads

15,829

Version

1.2.0

License

ISC

Last publish

Collaborators

  • refractalize