envsubst 0.2.0

  • README.md
  • Installing
  • Versions
  • 0


Build Status

Docker style environment variables substitution for Dart.

Environment variables are notated either with $variable_name or ${variable_name}. They are treated equivalently and the brace syntax is typically used to address issues with variable names with no whitespace, like ${foo}_bar.

The ${variable_name} syntax also supports a few of the standard bash modifiers as specified below:

  • ${variable:-word} indicates that if variable is set then the result will be that value. If variable is not set then word will be the result.
  • ${variable:+word} indicates that if variable is set then word will be the result, otherwise the result is the empty string.

In all cases, word can be any string, including additional environment variables.

Escaping is possible by adding a \ before the variable: $foo or ${foo}, for example, will translate to $foo and ${foo} literals respectively.


Using envsubst programatically

import 'package:envsubst/envsubst.dart';

main() {
  String input = r'Hello $HOME';
  String output = envSubst(input);
  print(output); // print 'Hello /Users/kseo'

Using via cli

$ envsubst.dart < input.txt > output.txt
$ echo 'welcome $HOME' | envsubst

Other Projects

If you are a Go programmer, see a8m/envsubst.



  • Add a command line tool
  • Add EnvSubst class which implements Converter<String, String> interface


  • Fix a parse error


  • Initial version

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  envsubst: ^0.2.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:envsubst/envsubst.dart';
Version Uploaded Documentation Archive
0.2.0 Oct 12, 2016 Go to the documentation of envsubst 0.2.0 Download envsubst 0.2.0 archive
0.1.1 Sep 30, 2016 Go to the documentation of envsubst 0.1.1 Download envsubst 0.1.1 archive
0.1.0 Sep 30, 2016 Go to the documentation of envsubst 0.1.0 Download envsubst 0.1.0 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0