I'm trying to write a command line utility in node.js. As one of the features it should change the current working directory of the shell it was called from. Something like node.js version of cd
. Is it possible to achieve this? If so, how?
To clarify, I'd like to be able to change the current directory in the terminal window by running the script.
/some/path> ...
/some/path> nodecd /other/path
/other/path> ...
The problem is that process.chdir()
works for the SCRIPT directory, not for the SHELL directory. I need to be able to somehow pass the current shell through the bash invocation to node script, and alter the path of that shell within the script - creating a subshell won't solve the problem.