Get the current path in the subprocess started by KillableProcessHandler

Answered

Hi, I started a nodejs process like '/[NODE_HOME]/node /Users/[USER]/workspace/my-intellij-extension/build/idea-sandbox/plugins/my-plugin/dist/myscript.js' by using KillableProcessHandler. And It works well, I can attach the nodejs thread to debug my code in myscript.js. But when I get the path of myscript.js with process.cwd() in the script file, it get the path which is "/Users/[USER]/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIU/2021.2.1/382c0b089ef214062b04298f4537997f79fc6090/ideaIU-2021.2.1/bin" not the path "/Users/[USER]/workspace/my-intellij-extension/build/idea-sandbox/plugins/my-plugin/dist/" which I'm expecting. 
Any ideas about this? I know I can pass the current path from native to the script, just want to know if there is another way?
Thank you very much for any help!

0
1 comment
Avatar
Sergey Simonchik
Official comment

Probably, when building a command line, current working directory wasn't set. As a result, it's inherited from the parent process - IDE.
If you're using `com.intellij.execution.configurations.GeneralCommandLine` to build the command line, please use `com.intellij.execution.configurations.GeneralCommandLine#setWorkDirectory` to set path to the folder of the script file.

Please sign in to leave a comment.