UNPKG

@catladder/cli

Version:

Panter cli tool for cloud CI/CD and DevOps

35 lines (34 loc) 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.collapseableSection = exports.repeatOnFailure = exports.sanitizeForBashVariable = exports.allowFailureInScripts = void 0; const globalScriptFunctions_1 = require("../globalScriptFunctions"); const allowFailureInScripts = script => ["set +e", // disable fail job on error ...script, "set -e" // reenable ]; exports.allowFailureInScripts = allowFailureInScripts; const sanitizeForBashVariable = name => name.replace(/-/g, "_"); exports.sanitizeForBashVariable = sanitizeForBashVariable; const repeatOnFailure = (command, options) => { return ` until ${command} do echo "Trying again." sleep ${options.pauseInSeconds} done `; }; exports.repeatOnFailure = repeatOnFailure; const start = (0, globalScriptFunctions_1.registerGlobalScriptFunction)("collapseable_section_start", `local section_title="\${1}" local section_description="\${2:-$section_title}" echo -e "section_start:\`date +%s\`:\${section_title}[collapsed=true]\\r\\e[0K$\{section_description}" `); const end = (0, globalScriptFunctions_1.registerGlobalScriptFunction)("collapseable_section_end", `local section_title="\${1}" echo -e "section_end:\`date +%s\`:\${section_title}\\r\\e[0K" `); const collapseableSection = (name, header) => commands => { return [start.invoke(`"${name}"`, `"${header}"`), ...commands, end.invoke(`"${name}"`)]; }; exports.collapseableSection = collapseableSection;