yarn-completion: Breaks when there is }, in scripts
Having }, inside one of the scripts breaks autocompletion. MWE:
{
"scripts": {
"hello1": "echo 'hello1'",
"hello2": "echo 'hello2'",
"hello3": "echo 'hello3'",
"hello4": "echo 'hello4'",
"hello5": "echo 'hello5'"
}
}
yarn run hello →tab hello1 hello2 hello3 hello4 hello5 (ok)
npm run hello →tab hello1 hello2 hello3 hello4 hello5 (ok)
{
"scripts": {
"hello1": "echo 'hello1'",
"hello2": "echo '},'",
"hello3": "echo 'hello3'",
"hello4": "echo 'hello4'",
"hello5": "echo 'hello5'"
}
}
yarn run hello →tab hello1 hello2 (broken)
npm run hello →tab hello1 hello2 hello3 hello4 hello5 (still ok)
A real-world script that broke yarn completion was:
`"format": "prettier --write --ignore-path .gitignore \"{.,src/**,test/**}/{*.{j,t}s{x,},*.md,ts*.json}\"",
Could the reason be in this line? https://github.com/dsifford/yarn-completion/blob/689daceca5a3b9d3dea157bd30b59bd86fa3d09b/yarn-completion.bash#L42
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 19 (19 by maintainers)
Commits related to this issue
- Update instructions for macOS/Homebrew (#12) Addresses https://github.com/dsifford/yarn-completion/issues/10#issuecomment-368164821 — committed to dsifford/yarn-completion by kachkaev 6 years ago
Version
0.6.1should work in BSD sed now.Urrrrgh! BSD utils are going to be the death of me, I swear…
Glad to hear we’ve found the culprit. I’ll try and get this compatible with BSD as soon as feasible. Thanks for your patience.
Thanks for for your hint about GNU sed – turns out this is exactly what caused trouble! Originally, even after installing GNU bash,
man sedwas starting like:After I did
brew install gnu-sed --with-default-namesand restarted the Terminal, it changed to:Consequently, yarn autocompletion 0.6.0 began to work! 🎉
I’m a frequent user of the command line, but am no way an expert in bash versions and flavours of other standard tools. All this is pretty foggy to me, so thanks for your help with sorting things out! To summarise, this is what I had to do in order to get
yarn-completionon macOS High Sierra working:Hope this helps someone else in a similar situation!
@kachkaev I have no idea why this isn’t working for you. I just matched all my shell options to the ones you have enabled and it still works perfectly fine on my end.
The only thing I can think of that it might still be is that you’re using BSD sed. If you can confirm that the issue is still persisting even using GNU sed, then I’m out of ideas and will have to unfortunately wait until more people report this issue.
I’ll try in on my macbook here in the next hour or so and see if it’s a mac quirk or something.