melos
melos copied to clipboard
fix: [Windows] Multiple command with `melos run` does not work
Is there an existing issue for this?
- [X] I have searched the existing issues.
Version
2.9.0
Description
On Windows if you run melos run my_script
and my_script
contains multiple commands it will only be executed the first command. It works properly on Linux
Steps to reproduce
Example script:
scripts:
my_script:
run: |
command1
command2
description: Script description
If you want to try on a real repo run melos run compile_icons
on this repo (you need to dart pub global activate vector_graphics_compiler
before)
Expected behavior
All the commands of the script are executed on Windows
Screenshots
No response
Additional context and comments
No response
This is making it difficult for us to use melos
on a project with Windows- and MacOS-based devs.
Same situation in the project I work on. There are scripts consisting of 4-5 sub-scripts I need to run one by one in correct order.
As a workaround on Windows you can use a single ampersand (&) to separate multiple commands on one command line. When a single ampersand is used, cmd.exe runs the first command, and then the second command.
command1 & command2
The new steps
feature solved this: https://melos.invertase.dev/configuration/scripts#steps
Cool!
But on Melos 5.2.2. I get:
melos.yaml: The property run at scripts/pre-commit is required but missing
when using the example from the documentation. Is the feature not yet available?
The new
steps
feature solved this: https://melos.invertase.dev/configuration/scripts#steps
I like the steps
feature, but to my understanding it doesn't really fix the issue. One major drawback is that steps seem to all run in the workspace root, so anything where you want to change the working dir in between requires the old &&
workaround again. See #705