bchatard / alfred-jetbrains

Alfred5 workflow to easily open your projects with your favorite JetBrains product.
MIT License
621 stars 49 forks source link

"Can't find application path for..." with shell scripts from Toolbox 1.19.7784 #185

Closed marcorieser closed 3 years ago

marcorieser commented 3 years ago

Describe the bug The latest Toolbox changes the structure of the shell script from open -na "/PATH/TO/APPS/DIRECTORY/PhpStorm.app/Contents/MacOS/phpstorm" --args "$@" to open -na "/PATH/TO/APPS/DIRECTORY/PhpStorm.app/Contents/MacOS/phpstorm" $wait --args "${ideargs[@]}" Because the current regular expression doesn't match with the new pattern, the path can not be found.

To Reproduce

Expected behavior A list of the last opened projects from PhpStorm.

Q A
Workflow version 1.4.4
OSX Version 10.15.7
Alfred Version 4.3 (1205)
JetBrains Product/Version PhpStorm / 2020.3
Toolbox Version 1.19.7784
Installation type JB Toolbox
Node version 14.3.0 (node --version)
NPM version 6.14.10 (npm --version)
cameronsstone commented 3 years ago

Thanks - this affected me for idea, too. I've made a different modification locally to fix it - I just removed the args part. EDIT: nope - needed more changes. MB. removed:

  const pattern = new RegExp('open -(n)?a "(.*)"( --args)? "\\$@"');
  const match = pattern.exec(binContent);
  const matchLength = match ? match.length : 0;

  if (match && [2, 4].includes(matchLength)) {

replaced with:

  const pattern = new RegExp('open -(n)?a "(.*)"');
  const match = pattern.exec(binContent);
  const matchLength = match ? match.length : 0;

  if (match && [2, 3].includes(matchLength)) {

This should work with the latest toolbox, and also the previous versions this regex supported. :-)

marcorieser commented 3 years ago

I have no old shell scripts available to test if my solution works with them. I just found an old shell script in another issue and made sure my regex catches this and my new shell script. Also did not really go trough the match logic below the regex to see which groups / parts are needed, just made sure the groups are the same as before. 😊

cameronsstone commented 3 years ago

Thanks @bchatard . Pulled the new code and everything is working perfectly. Cheers!

cameronsstone commented 3 years ago

Oh, and thanks, obviously, to @marcorieser , too!