MCPcopy Create free account
hub / github.com/Azure/powershell / getExecOutput

Function getExecOutput

lib/index.js:1699–1732  ·  view source on GitHub ↗

* Exec a command and get the output. * Output will be streamed to the live console. * Returns promise with the exit code and collected stdout and stderr * * @param commandLine command to execute (can include additional args). Must be correctly escaped. * @param args

(commandLine, args, options)

Source from the content-addressed store, hash-verified

1697 * @returns Promise<ExecOutput> exit code, stdout, and stderr
1698 */
1699function getExecOutput(commandLine, args, options) {
1700 var _a, _b;
1701 return __awaiter(this, void 0, void 0, function* () {
1702 let stdout = '';
1703 let stderr = '';
1704 //Using string decoder covers the case where a mult-byte character is split
1705 const stdoutDecoder = new string_decoder_1.StringDecoder('utf8');
1706 const stderrDecoder = new string_decoder_1.StringDecoder('utf8');
1707 const originalStdoutListener = (_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stdout;
1708 const originalStdErrListener = (_b = options === null || options === void 0 ? void 0 : options.listeners) === null || _b === void 0 ? void 0 : _b.stderr;
1709 const stdErrListener = (data) => {
1710 stderr += stderrDecoder.write(data);
1711 if (originalStdErrListener) {
1712 originalStdErrListener(data);
1713 }
1714 };
1715 const stdOutListener = (data) => {
1716 stdout += stdoutDecoder.write(data);
1717 if (originalStdoutListener) {
1718 originalStdoutListener(data);
1719 }
1720 };
1721 const listeners = Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.listeners), { stdout: stdOutListener, stderr: stdErrListener });
1722 const exitCode = yield exec(commandLine, args, Object.assign(Object.assign({}, options), { listeners }));
1723 //flush any remaining characters
1724 stdout += stdoutDecoder.end();
1725 stderr += stderrDecoder.end();
1726 return {
1727 exitCode,
1728 stdout,
1729 stderr
1730 };
1731 });
1732}
1733exports.getExecOutput = getExecOutput;
1734//# sourceMappingURL=exec.js.map
1735

Callers

nothing calls this directly

Calls 1

execFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…