Note: When possible, we encourage you to build a dedicated extension to better support features you are looking for (and help out the community). eg. $aws directive instead of the above.
Installing
Install and use:
yarn add @app-config/exec
In .app-config.meta.yml file:
parsingExtensions:
- '@app-config/exec'
Options
The following options can be passed to each $exec directive:
The command to run. Should be a single string containing both command and arguments. The command's stdout will be used as the resulting value. Runs in a shell, /bin/sh on Unix and process.env.ComSpec on Windows.
trimWhitespace: boolean:
If true, automatically trim whitespace from the start and end of the command's output. Useful to remove the trailing newline produced by most commands. If false, output will be left in its raw form. Default true.
parseOutput: boolean:
If true, automatically guess output content type (YAML, TOML, JSON, or JSON5) and parse. Throws if parse fails. If false, output will be read as a string. Default false.
failOnStderr: boolean:
If true, fail if any output is found in command's stderr. Default false.
App Config Exec Plugin
Run arbitrary programs or shell commands to generate config. Serves as a nice fallback/stop-gap if an extension you need doesn't yet exist.
Usage
Basic:
Auto-parse output as YAML/TOML/JSON/JSON5:
Build a custom script to generate config:
Retrieve arbitrary information:
Node v8 version:
System's architecture:
Retrieve list of AWS S3 buckets via
aws
&jq
CLI:Note: When possible, we encourage you to build a dedicated extension to better support features you are looking for (and help out the community). eg.
$aws
directive instead of the above.Installing
Install and use:
In
.app-config.meta.yml
file:Options
The following options can be passed to each
$exec
directive:command: string
:The command to run. Should be a single
string
containing both command and arguments. The command'sstdout
will be used as the resulting value. Runs in a shell,/bin/sh
on Unix andprocess.env.ComSpec
on Windows.trimWhitespace: boolean
:If
true
, automatically trim whitespace from the start and end of the command's output. Useful to remove the trailing newline produced by most commands. Iffalse
, output will be left in its raw form. Defaulttrue
.parseOutput: boolean
:If
true
, automatically guess output content type (YAML, TOML, JSON, or JSON5) and parse. Throws if parse fails. Iffalse
, output will be read as astring
. Defaultfalse
.failOnStderr: boolean
:If
true
, fail if any output is found in command'sstderr
. Defaultfalse
.