invertase / melos

🌋 A tool for managing Dart projects with multiple packages. With IntelliJ and Vscode IDE support. Supports automated versioning, changelogs & publishing via Conventional Commits.
https://melos.invertase.dev/~melos-latest
Apache License 2.0
1.07k stars 193 forks source link

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

Open timcreatedit opened 2 months ago

timcreatedit commented 2 months ago

Is there an existing issue for this?

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

spydon commented 2 months ago

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

timcreatedit commented 2 months ago

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?

spydon commented 2 months ago

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.

timcreatedit commented 2 months ago

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?

spydon commented 2 months ago

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 commented 1 month ago

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