docs(readme): update variable expansion docs

This commit is contained in:
Todd Bluhm 2020-02-10 20:00:47 -06:00
parent 065b110048
commit 361f731f88
No known key found for this signature in database
GPG Key ID: 9CF312607477B8AB

View File

@ -146,13 +146,25 @@ commands together that share the same environment variables.
EnvCmd supports expanding `$var` values passed in as arguments to the command. The allows a user
to provide arguments to a command that are based on environment variable values at runtime.
**NOTE:** You must escape the `$` character with `\` or your terminal might try to auto expand it before passing it to `env-cmd`.
**Terminal**
```sh
# $USER will be expanded into the env value it contains at runtime
./node_modules/.bin/env-cmd -x node index.js --user=$USER
# $VAR will be expanded into the env value it contains at runtime
./node_modules/.bin/env-cmd -x node index.js --arg=\$VAR
```
or in `package.json` (use `\\` to insert a literal backslash)
```json
{
"script": {
"start": "env-cmd -x node index.js --arg=\\$VAR"
}
}
```
### `--silent` suppresses env-cmd errors
EnvCmd supports the `--silent` flag the suppresses all errors generated by `env-cmd`