MCPcopy Create free account
hub / github.com/angular/dev-infra / exec

Method exec

github-actions/saucelabs/set-saucelabs-env.js:20285–20385  ·  view source on GitHub ↗

* Exec a tool. * Output will be streamed to the live console. * Returns promise with return code * * @param tool path to tool to exec * @param options optional exec options. See ExecOptions * @returns number

()

Source from the content-addressed store, hash-verified

20283 * @returns number
20284 */
20285 exec() {
20286 return __awaiter4(this, void 0, void 0, function* () {
20287 if (!isRooted(this.toolPath) && (this.toolPath.includes("/") || IS_WINDOWS2 && this.toolPath.includes("\\"))) {
20288 this.toolPath = path3.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath);
20289 }
20290 this.toolPath = yield which(this.toolPath, true);
20291 return new Promise((resolve2, reject) => __awaiter4(this, void 0, void 0, function* () {
20292 this._debug(`exec tool: ${this.toolPath}`);
20293 this._debug("arguments:");
20294 for (const arg of this.args) {
20295 this._debug(` ${arg}`);
20296 }
20297 const optionsNonNull = this._cloneExecOptions(this.options);
20298 if (!optionsNonNull.silent && optionsNonNull.outStream) {
20299 optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os3.EOL);
20300 }
20301 const state = new ExecState(optionsNonNull, this.toolPath);
20302 state.on("debug", (message) => {
20303 this._debug(message);
20304 });
20305 if (this.options.cwd && !(yield exists(this.options.cwd))) {
20306 return reject(new Error(`The cwd: ${this.options.cwd} does not exist!`));
20307 }
20308 const fileName = this._getSpawnFileName();
20309 const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName));
20310 let stdbuffer = "";
20311 if (cp.stdout) {
20312 cp.stdout.on("data", (data) => {
20313 if (this.options.listeners && this.options.listeners.stdout) {
20314 this.options.listeners.stdout(data);
20315 }
20316 if (!optionsNonNull.silent && optionsNonNull.outStream) {
20317 optionsNonNull.outStream.write(data);
20318 }
20319 stdbuffer = this._processLineBuffer(data, stdbuffer, (line) => {
20320 if (this.options.listeners && this.options.listeners.stdline) {
20321 this.options.listeners.stdline(line);
20322 }
20323 });
20324 });
20325 }
20326 let errbuffer = "";
20327 if (cp.stderr) {
20328 cp.stderr.on("data", (data) => {
20329 state.processStderr = true;
20330 if (this.options.listeners && this.options.listeners.stderr) {
20331 this.options.listeners.stderr(data);
20332 }
20333 if (!optionsNonNull.silent && optionsNonNull.errStream && optionsNonNull.outStream) {
20334 const s = optionsNonNull.failOnStdErr ? optionsNonNull.errStream : optionsNonNull.outStream;
20335 s.write(data);
20336 }
20337 errbuffer = this._processLineBuffer(data, errbuffer, (line) => {
20338 if (this.options.listeners && this.options.listeners.errline) {
20339 this.options.listeners.errline(line);
20340 }
20341 });
20342 });

Callers 10

parseChangelogEntryFunction · 0.45
runCommandsFunction · 0.45
checkPortabilityFunction · 0.45
generateFunction · 0.45
transformFunction · 0.45
expandFunction · 0.45
parseMetadataFunction · 0.45
parseMetadataFunction · 0.45
execFunction · 0.45

Calls 15

__awaiter4Function · 0.70
isRootedFunction · 0.70
whichFunction · 0.70
existsFunction · 0.70
_debugMethod · 0.45
_cloneExecOptionsMethod · 0.45
writeMethod · 0.45
_getCommandStringMethod · 0.45
onMethod · 0.45
_getSpawnFileNameMethod · 0.45
_getSpawnArgsMethod · 0.45
_getSpawnOptionsMethod · 0.45

Tested by

no test coverage detected