介面:ExtensionVM
目錄
自
0.2.0
屬性
cli
• 唯讀
cli: ExtensionCli
在後端容器中執行指令。
範例:在後端容器中執行指令 ls -l
await ddClient.extension.vm.cli.exec(
"ls",
["-l"]
);
串流後端容器中執行的指令輸出。
當擴充功能使用多個容器定義自己的 compose.yaml
檔案時,指令會在定義的第一個容器上執行。更改容器的定義順序,即可在另一個容器上執行指令。
範例:在後端容器中產生指令 ls -l
await ddClient.extension.vm.cli.exec("ls", ["-l"], {
stream: {
onOutput(data): void {
// As we can receive both `stdout` and `stderr`, we wrap them in a JSON object
JSON.stringify(
{
stdout: data.stdout,
stderr: data.stderr,
},
null,
" "
);
},
onError(error: any): void {
console.error(error);
},
onClose(exitCode: number): void {
console.log("onClose with exit code " + exitCode);
},
},
});
參數
要執行的指令。
參數
要執行的指令的參數。
參數
用於監聽指令輸出資料和錯誤的回呼函式。
service
• 選用
唯讀
service: HttpService