melos icon indicating copy to clipboard operation
melos copied to clipboard

fix: [Windows] Multiple command with `melos run` does not work

Open ferraridamiano opened this issue 2 years ago • 2 comments

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

ferraridamiano avatar Feb 08 '23 10:02 ferraridamiano

This is making it difficult for us to use melos on a project with Windows- and MacOS-based devs.

matthew-james-wooliesx avatar Oct 20 '23 00:10 matthew-james-wooliesx

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.

tomwyr avatar Oct 20 '23 13:10 tomwyr

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

JesperBllnbm avatar Mar 27 '24 09:03 JesperBllnbm

The new steps feature solved this: https://melos.invertase.dev/configuration/scripts#steps

spydon avatar Mar 27 '24 10:03 spydon

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?

JesperBllnbm avatar Mar 28 '24 11:03 JesperBllnbm

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

timcreatedit avatar Apr 23 '24 09:04 timcreatedit