Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 1x 1x 1x 1x 1x 1x 1x 5x 5x 5x 5x 5x 5x 5x 1x 10x 1x 12x 10x 10x 10x 10x 10x 10x 10x 2x 1x 4x 1x 11x 11x 11x 1x 4x | "use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.setFailure = exports.validateInput = exports.setOutputParam = exports.getInputParam = exports.runCommand = void 0;
const shelljs_1 = require("shelljs");
// @ts-ignore
const os_1 = __importDefault(require("os"));
const lib_1 = require("@aws/codecatalyst-adk-utils/lib");
function runCommand(cmd, sanitizeInput = true, disableStdInput = true, args) {
const command_output = {};
const sanitizedCommand = disableStdInput
? redirectStdInputToDevNull((0, lib_1.sanitizeCommand)(cmd, sanitizeInput, args))
: (0, lib_1.sanitizeCommand)(cmd, sanitizeInput, args);
const shell_command = (0, shelljs_1.exec)(sanitizedCommand, { async: false });
command_output.code = shell_command.code;
command_output.stdout = shell_command.stdout;
command_output.stderr = shell_command.stderr;
return command_output;
}
exports.runCommand = runCommand;
function getInputParam(inputVar) {
return process.env[inputVar] === undefined ? '' : process.env[inputVar];
}
exports.getInputParam = getInputParam;
function setOutputParam(varName, varValue) {
if (!(0, lib_1.isValidOutputVariableName)(varName)) {
const errorMessage = `Invalid output parameter name, it must match the following pattern ${lib_1.outputVariableNamePattern}`;
const command_output = {};
command_output.code = 1;
command_output.stdout = errorMessage;
command_output.stderr = errorMessage;
setFailure(errorMessage, 1);
return command_output;
}
return runCommand(`echo "::set-output name=${varName}::${varValue}"`, false).stdout;
}
exports.setOutputParam = setOutputParam;
function validateInput(inputVar) {
return inputVar === null || inputVar === void 0 ? void 0 : inputVar.replace(/\n/g, '');
}
exports.validateInput = validateInput;
function setFailure(message, exitCode) {
process.exitCode = exitCode;
const errorText = message.toString();
process.stdout.write(errorText + os_1.default.EOL);
}
exports.setFailure = setFailure;
function redirectStdInputToDevNull(cmd) {
return cmd + ' < /dev/null';
}
|