Closed kachkaev closed 6 years ago
Agree.
I added exec
yesterday actually. Wasn't sure what it was for so I didn't enable path expansion. All that would need to be done is enabling path expansion in the compgen call for exec.
Re-reading this now and I think I may have misinterpreted your question. Are you saying you'd want to add path expansion to all custom scripts? Or just the new exec
command?
If the former, what does npm do in that situation?
Looks like npm does path autocompletion in these cases:
npm sr
→ npm src/
(but not just after npm
or npm s
)npm XYZ s
→ npm XYZ src/
npm XYZ
→ [ls] (but not just after npm run
)npm run XYZ [...XYZ] s
→ npm run XYZ [...XYZ] src
npm run XYZ [...XYZ]
→ [ls]This behaviour makes sense to me and it feels more or less reasonable for yarn completion too. I don't think we should do path autocompletion after yarn exec
only – this is just an arbitrary script name.
BTW I had to update my custom scripts:
"exec": "ts-node",
"exec:watch": "ts-node-dev --respawn --notify=false",
↓
"exe": "ts-node",
"exe:watch": "ts-node-dev --respawn --notify=false",
It turned out that exec
is some deprecated command in yarn, which causes glitches when I omit run
. Typing yarn run exec
worked OK while yarn exec
was giving an error (because a special yarn
's command was called, not my script). Both yarn run exe path/to/file.js
and yarn exe path/to/file.js
behave well and it'll be great to have path autocompletion in them one day! 👍
exec
is actually a brand new command that hasn't been documented yet. It was just released (IIRC) on their last minor release.
Adding path completion is on my todo list. Haven't gotten around to it just yet because it'll take about an hour to get finished up. Hopefully gonna sit down and work on that and also the workspace(s) subcommands one of these next coming days.
@kachkaev Give 0.7.0
a shot and let me know how that works for you
Thank you for working on this update 0.7
– I'm really looking forward to using the new features!
It's probably something to do with macOS again, but after grabbing the new version and trying yarn [tab]
in a new Terminal, I'm getting:
yarn -bash: compopt: command not found
-bash: compopt: command not found
bash --version
GNU bash, version 4.4.19(1)-release (x86_64-apple-darwin17.3.0)
Urggggggh. I hate mac. :rage:
What version of bash-completion do you have installed? I've found recently that the regular one in Homebrew is not the one people with updated versions of bash should be using..
Can you try installing instead bash-completion@2
(the name might not be exactly that, but it'll turn up when you search for it)
The regular bash-completion
is a waaaaaaaay outdated branch that assumes bash 3 is installed.
You're right, I had bash-completion
instead of bash-completion@2
!
After brew uninstall bash-completion
, brew install bash-completion@2
and updating ~/.bash_profile
, I started getting this in every new terminal:
So looks like one of my installed completions is not working with @2
:
yarn-completion
still does not work:
Switched back to bash-completion
for now.
@kachkaev declare -A
is a bash 4 option. All versions of bash 4 should support it.
So it looks like your login shell might not be bash 4?
You are right, it was not. I had to open Terminal settings and set Command to what I got in which bash
(for Homebrew bash):
All works now! 🎉 ❤️
Awesome, glad to hear.
For others who might also read this, you can also change your login shell by typing chsh
in the terminal itself.
Strangely, chsh
did not work for me. After changing Shell: /bin/bash
with Shell: /usr/local/bin/bash
(i.e. Homebrew's bash) and saving the file with :wq
, I got the following error:
chsh: /usr/local/bin/bash: non-standard shell
re-edit the password file?
🤔
UPD: solution
Hi again @dsifford 👋
I've noticed one more difference between npm completion and yarn completion and decided to share. It is to do with file paths. Here's the use case:
I've got a TypeScript / Node.js project, which stores a few data-processing actions. Folder structure looks like so:
Every file in
src/actions
is an entry point, which I could run just asnode src/actions/do-this.js
if they were written in pure JavaScript. The most straightforward alternative for TypeScript is to go forts-node src/actions/do-this.ts
, assuming thatts-node
is globally installed. However, a local copy ofts-node
is better, especially if the project is shared between multiple people.A pretty handy alternative to typing
node_modules/.bin/ts-node src/actions/do-this.ts
can be creating simple proxy scripts inpackage.json
:The commands become shorter:
In these cases, it'd be great if yarn-completion could hint users with the paths, say after typing
yarn exec src/actions/d
+tab
. This feature is already supported in npm:npm run exec:watch src/ac
→npm run exec:watch src/actions/
etc.WDYT?