简体   繁体   English

如何在终端中使用 vscode 扩展运行命令

[英]how to vscode extension run commands in the terminal

const { spawn } = require('child_process');
// want run command
// ~/zcfh/umlgen/build/bin/umlgen /Users/zcfh/zcfh/tmp1.cpp -o=~/zcfh/t.txt
const ls = spawn('~/zcfh/umlgen/build/bin/umlgen ', ['/Users/zcfh/zcfh/tmp1.cpp',"-o=~/zcfh/t.txt"]);

It seems that using child_process can run commands in the terminal.使用 child_process 好像可以在终端运行命令。 I want to be able to run a binary program in the terminal.我希望能够在终端中运行二进制程序。 Any good comments or references?有什么好的意见或参考吗?

const { execFile } = require('child_process');
const umlgen = execFile(cmd, args, { cwd: workingPath });
umlgen.stdout.on('data', (data: Uint8Array) => {
  console.log(`stdout: ${data}`);
});
let errMessage: string = "";
umlgen.stderr.on('data', (data: Uint8Array) => {
  console.error(`stderr: ${data}`);
});

umlgen.on('close', (code: number) => {
  console.log(`close: ${code}`);
});

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

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