melos icon indicating copy to clipboard operation
melos copied to clipboard

fix: `steps` seem to run independent from each other

Open timcreatedit opened this issue 10 months ago • 6 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues.

Version

5.3.0

Description

When defining a script with multiple steps, the working directory from the previous step doesn't seem to be maintained for the next step. This means steps is not a working fix for #470 as far as I understand.

Steps to reproduce

  1. Define a script with multiple steps such as:
fail:
    steps:
      - cd packages/
      - pwd
  1. Run the script melos run fail

Expected behavior

The script should print {workspace_root}/packages, but the second step happens in the workspace root again.

Screenshots

No response

Additional context and comments

No response

timcreatedit avatar Apr 23 '24 09:04 timcreatedit

What do you think @jessicatarra, would it make sense running all the steps in the same context?

spydon avatar Apr 23 '24 10:04 spydon

I would understand if you keep it like this (also because it's more consistent with GitHub workflows), but then I feel like we would need to be clear about that in the docs and reopen #470?

timcreatedit avatar Apr 23 '24 11:04 timcreatedit

I would understand if you keep it like this (also because it's more consistent with GitHub workflows), but then I feel like we would need to be clear about that in the docs and reopen #470?

I don't think 470 is exactly about this use-case so it's better to use a new issue for that.

spydon avatar Apr 23 '24 11:04 spydon

I don't think 470 is exactly about this use-case so it's better to use a new issue for that.

While it's not specifically about this, it was closed with the reason that steps provides a fix for it. This suggests that

run: |
  command1
  command2

(which didn't work on windows) is equivalent to the new

steps:
  - command1
  - command2

But it isn't, as long the steps are executed in different contexts. So I think the issue should remain open, since there is still no way to get a multi command script to work on windows without resorting to &, or am I missing something?

timcreatedit avatar Apr 23 '24 12:04 timcreatedit

So I think the issue should remain open, since there is still no way to get a multi command script to work on windows without resorting to &, or am I missing something?

I think that is how it is intended to be (it's kind of just abusing a yaml feature to support multiple lines), Melos doesn't transform the result into a shell script with multiple lines.

spydon avatar Apr 23 '24 13:04 spydon

This issue will be solved by https://github.com/invertase/melos/pull/711

spydon avatar Jun 05 '24 08:06 spydon