1

In PhpStorm (as well as other JetBrains IDEs, I'm sure), I'm setting up a File Watcher. In the Watcher Settings section, it asks me to specify the path to the program to be executed.

I want to use the executable file within the node_modules/.bin directory of my project. I don't want it installed globally because I may have other projects that use the same program, but may require a different version.

I could simply specify the absolute path to my project's node_modules/.bin directory, but then if I move the project, the file watcher will break.

In the Arguments and Output paths to refresh fields just below the Program field, it allows you to insert a macro, like $Projectpath$. This is exactly what I need, but it doesn't look like the Program field allows that.

Is there a way to specify a relative path for the Program field?

Here is a screenshot of the File Watcher setup window:

PhpStorm File Watcher setup window

Travesty3
  • 14,351
  • 6
  • 61
  • 98

1 Answers1

2

I could simply specify the absolute path to my project's node_modules/.bin directory, but then if I move the project, the file watcher will break.

That's not true -- at very least it does not break anything here -- got 3 projects that use local stuff.

Is there a way to specify a relative path for the Program field?

Sure. Use full path to the program :)

Internally (in config file) it will be stored using $PROJECT_DIR$ (AFAIK) special macro/variable but in actual field (in that dialog window) you will always see full path. Such conversion is done automatically.

You can read a bit more here (in comments): https://youtrack.jetbrains.com/issue/WEB-24376


If you are using the same project on different computers ... where path to the same program will be different but outside of the project (e.g. stored inside user-specific folder and user logins/names are different on such computers) ... you could use Path Variables functionality (Settings/Preferences | Appearance & Behavior | Path Variables) and specify the same variable on all of such computers that would point to correct path on that computer. IDE will automatically use that path variable to store the path.

So .. on one computer MY_TOOL_PATH will be pointing to /Users/Joe/MyTool and on another it could be /Users/Sam/AnotherTool.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
  • You're right...I didn't realize it would convert the full path that I specify to a relative path when stored. This doesn't seem obvious at all. I'll leave a comment on the YouTrack issue. Thanks! – Travesty3 Apr 26 '17 at 14:01