Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Melos scripts not parsing args fully #643

Open
1 task done
shmink opened this issue Feb 7, 2024 · 7 comments
Open
1 task done

Melos scripts not parsing args fully #643

shmink opened this issue Feb 7, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@shmink
Copy link

shmink commented Feb 7, 2024

Is there an existing issue for this?

  • I have searched the existing issues.

Version

3.2.0

Description

There's similar issues but I don't think they're exact in the same issues I'm seeing.

It seems to be that one can pass arguments to a melos script just as you would a bash script but the issue is that melos isn't working out where one argument begins and ends correctly.

Steps to reproduce

For example, from my melos.yaml file I have the following

  translations:test:
    run: $MELOS_ROOT_PATH/scripts/translations/test.sh

That test.sh file is below

echo "arg 1: "$1
echo "arg 2: "$2
echo "arg 3: "$3

If I run the script directly I get the following

~/work/app
❯ ./scripts/translations/test.sh "Hey there" "how" "are you?" 
arg 1: Hey there
arg 2: how
arg 3: are you?

If I run the melos version which is just pointing at the same script it does accept the arguments but I don't think it takes " " speech marks into account.

~/work/app                                                                                            
❯ melos translations:test "Hey there" "how" "are you?"
melos run translations:test
  └> $MELOS_ROOT_PATH/scripts/translations/test.sh Hey there how are you?
     └> RUNNING

arg 1: Hey
arg 2: there
arg 3: how

melos run translations:test
  └> $MELOS_ROOT_PATH/scripts/translations/test.sh Hey there how are you?
     └> SUCCESS

It looks like it sees ANY space as a separation in arguments.

Expected behavior

I would expect

~/work/app                                                                                            
❯ melos translations:test "Hey there" "how" "are you?"
melos run translations:test
  └> $MELOS_ROOT_PATH/scripts/translations/test.sh Hey there how are you?
     └> RUNNING

arg 1: Hey there
arg 2: how
arg 3: are you?

melos run translations:test
  └> $MELOS_ROOT_PATH/scripts/translations/test.sh Hey there how are you?
     └> SUCCESS

Screenshots

No response

Additional context and comments

No response

@shmink shmink added the bug Something isn't working label Feb 7, 2024
@spydon
Copy link
Collaborator

spydon commented Feb 7, 2024

Not that there should be any difference, but could you just verify that it is the same in the latest version (v4.1.0)?

@shmink
Copy link
Author

shmink commented Feb 7, 2024

Unfortunately, I cannot due to dependency conflicts with the repo I work on. I was kind of hoping that some kind soul could just copy and paste my examples above as even creating a new project I run into other issues.

@spydon
Copy link
Collaborator

spydon commented Feb 7, 2024

You most likely have your monorepo set up in the wrong way if you get a dependency conflict with melos, check the recommended structure here (only melos should be in the root workspace pubspec):
https://melos.invertase.dev/getting-started#recommended-directory-structure

@shmink
Copy link
Author

shmink commented Feb 7, 2024

That structure looks like what I have but I'd rather stay on topic please.

@spydon
Copy link
Collaborator

spydon commented Feb 7, 2024

It is on topic, because if you can't test with the latest version it is much harder for us to debug.

@shmink
Copy link
Author

shmink commented Feb 7, 2024

Fair enough. Finally managed to do it and yes the results are the same for v4.1

~/example                                                                                                                              
❯ melos --version
4.1.0

~/example                                                                                                                              
❯ ./test.sh "Hey there" "are" "you okay?"
arg 1: Hey there
arg 2: are
arg 3: you okay?

~/example                                                                                                                              
❯ cat melos.yaml 
name: example
sdkPath: .fvm/flutter_sdk

packages:
  - "*"

scripts:
  test:
    run: $MELOS_ROOT_PATH/test.sh

~/example                                                                                                                              
❯ melos test "Hey there" "are" "you okay?"
melos run test
  └> $MELOS_ROOT_PATH/test.sh Hey there are you okay?
     └> RUNNING

arg 1: Hey
arg 2: there
arg 3: are

melos run test
  └> $MELOS_ROOT_PATH/test.sh Hey there are you okay?
     └> SUCCESS

Still seems to be that melos sees any space as a separation in arguments ignoring cases where anything surrounded by speech marks should count as 1 argument.

In fact, in the final output it looks like " has been stripped out all together.

melos run test
  └> $MELOS_ROOT_PATH/test.sh Hey there are you okay?
     └> SUCCESS

@spydon
Copy link
Collaborator

spydon commented Apr 15, 2024

Can you try just doing MELOS_ROOT_PATH, without the $?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants