简体   繁体   English

无法从扩展中使用 VSCode CLI

[英]Unable to use VSCode CLI from extension

I am trying to create an extension and want to use 'code --version' inside child_process, but always it is return version of 'node'.我正在尝试创建一个扩展并想在 child_process 中使用“code --version”,但它始终是“node”的返回版本。 from commandline I was able to use code --version without any issue.从命令行我可以毫无问题地使用 code --version 。

Code:-代码:-

var output = child.spawnSync("code",['--version']);
vscode.window.showInformationMessage(`${output.stdout}.`)

One thing I have noticed is always 'code' is considered as 'node' with in child process.我注意到的一件事是“代码”总是被视为子进程中的“节点”。 Could someone help me to identify the cause of this issue.有人可以帮我找出这个问题的原因。

Thank You.谢谢你。 Chaithanya柴塔尼亚

Found that the process is running under VSCode installation folder which have code.exe.发现进程运行在VSCode安装文件夹下,里面有code.exe。 After changing code to below lines, it started working as expected.将代码更改为以下行后,它开始按预期工作。

const bat = child.execSync('bin\\code --list-extensions');
console.error(bat.toString());

Thank You.谢谢你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM