如何获取在NodeJS上运行的程序中正在运行的VS Code示例的当前工作目录?

whhtz7ly  于 2023-03-22  发布在  Node.js
关注(0)|答案(1)|浏览(130)

在NodeJS中,我需要“访问”一个正在运行的VSCode示例,并查看当前工作目录是否是一个特定的文件夹,即“/home/foobar/Desktop/myproject”。
这在NodeJS中可能吗?

g6baxovj

g6baxovj1#

在Unix系统上,请参阅Find out current working directory of a running process?pwdx <PID>和其他方法)。在Windows系统上,请参阅windows batch command to determine working directory of a process(安装执行此工作的非本机程序的建议)和Is it possible to determine the working directory of another process?(如何使用Windows API执行此操作,我不知道是否可以通过NodeJS直接访问)。至少在UNIX系统上,您可以使用child_process(另请参阅Execute a command line binary with Node.js)。

相关问题