These variables are available as environment variables in the commands run by
melos exec and in exec scripts:
melos:
scripts:
echo:vars:
exec: echo $MELOS_PACKAGE_NAME $MELOS_PACKAGE_VERSION $MELOS_PACKAGE_PATHThe variables that describe a package only exist while melos exec runs a
command in that package. When you call melos exec yourself, from a terminal or
from a run script, a POSIX shell expands
$MELOS_PACKAGE_NAME to an empty string before Melos starts. Wrap the command
in single quotes, or escape the reference as \$MELOS_PACKAGE_NAME, so that the
shell started by melos exec expands it instead:
melos exec -- 'echo $MELOS_PACKAGE_NAME'A command substitution in an exec script still runs once, before melos exec
starts, so the package variables are not defined inside of it. Escape the
substitution to run it in every package instead:
melos:
scripts:
echo:directory:
exec: echo \$(basename $MELOS_PACKAGE_PATH)$MELOS_PACKAGE_NAME is also replaced in the paths passed to the
--file-exists package filter:
melos exec --file-exists='test_driver/$MELOS_PACKAGE_NAME_e2e.dart' -- echo helloThe path to the mono-repo root
The name of the package that's currently executing a script (when using
melos exec)
The version of the package that's currently executing a script (when using
melos exec)
The path of the package that's currently executing a script (when using
melos exec).
The name of the parent package of the example that's currently being executed
in a script (when using melos exec).
The version of the parent package of the example that's currently being executed
in a script (when using melos exec).
The path of the parent package of the example that's currently being executed
in a script (when using melos exec).
Whether the current publish is a dry run or not. This is true when running
melos publish --dry-run and false otherwise.
If an example package exists in a directory that is a child of another package,
then its parent is the 'parent package'. For example; the package
firebase_auth has an example directory that is also a package, when running
a melos exec script in the example package then the parent package would be
firebase_auth.
Note, this 'parent package' functionality only currently works when the 'child
package' name ends with example.
Define a comma delimited list of package names that Melos should focus on. This
will act as the scope global package filter, and it will override the scope
for all the filtering options defined in the packageFilters section.
Melos also sets this variable itself when running a script that declares
packageFilters, so that a melos
command invoked by the script is scoped to the selected packages.
The path to the Dart/Flutter SDK to use. This environment variable has
precedence over the sdkPath option in the root pubspec.yaml, but is
overridden by the command line option --sdk-path.
Set to true to only print warnings, errors and the output of failed commands.
This environment variable has precedence over the
quiet option in the root pubspec.yaml, but
is overridden by the command line options --quiet and --no-quiet.
Melos also sets this variable itself for the scripts that it runs in quiet mode,
so that a melos command invoked by a script is quiet too.
Set to true to make melos exec run the command
in every package, even in the packages in which the sources did not change. This
has the same effect as the command line option --run-unchanged.
Melos also sets this variable itself for the scripts that it runs with
melos run --run-unchanged, so that it
applies to every melos exec command invoked by a script.
Set to true to make melos exec ignore the
sources of commands, so that they run in every package without calculating or
storing checksums, for example on a continuous integration server. This
environment variable has precedence over the
ignoreSources option in the root
pubspec.yaml, but is overridden by the command line options
--ignore-sources and --no-ignore-sources.
Melos also sets this variable itself for the scripts that it runs with
melos run --ignore-sources.
Set to true to make Melos style its output with colors, even if it does not
write to a terminal, for example on a continuous integration server. Set to
false to never style the output.
Melos also sets this variable itself for the scripts that it runs. Melos
captures the output of those scripts, so a melos command invoked by a script
cannot detect the terminal on its own and would otherwise lose its colors.
Other tools that are invoked by a script do not write to a terminal either, so
most of them turn off their colors. They usually have an option to turn colors
back on, for example flutter --color test or dart test --color. Scripts that
need a real terminal can use
stdio: inherit.

