36 lines
1.7 KiB
JavaScript
36 lines
1.7 KiB
JavaScript
|
"use strict";
|
||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
|
});
|
||
|
};
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
const tr = require("./toolrunner");
|
||
|
/**
|
||
|
* Exec a command.
|
||
|
* Output will be streamed to the live console.
|
||
|
* Returns promise with return code
|
||
|
*
|
||
|
* @param commandLine command to execute (can include additional args). Must be correctly escaped.
|
||
|
* @param args optional arguments for tool. Escaping is handled by the lib.
|
||
|
* @param options optional exec options. See ExecOptions
|
||
|
* @returns Promise<number> exit code
|
||
|
*/
|
||
|
function exec(commandLine, args, options) {
|
||
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
const commandArgs = tr.argStringToArray(commandLine);
|
||
|
if (commandArgs.length === 0) {
|
||
|
throw new Error(`Parameter 'commandLine' cannot be null or empty.`);
|
||
|
}
|
||
|
// Path to tool to execute should be first arg
|
||
|
const toolPath = commandArgs[0];
|
||
|
args = commandArgs.slice(1).concat(args || []);
|
||
|
const runner = new tr.ToolRunner(toolPath, args, options);
|
||
|
return runner.exec();
|
||
|
});
|
||
|
}
|
||
|
exports.exec = exec;
|
||
|
//# sourceMappingURL=exec.js.map
|