@codechecks/client
Version:
Open source platform for code review automation
40 lines • 1.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
const errors_1 = require("./utils/errors");
function runOrCatchError(fn) {
try {
return fn();
}
catch (_a) {
return undefined;
}
}
exports.runOrCatchError = runOrCatchError;
function getRequiredEnv(name) {
const value = process.env[name];
if (value === undefined) {
throw errors_1.crash(`Required env var ${name} missing`);
}
return value;
}
exports.getRequiredEnv = getRequiredEnv;
function normalizePath(absoluteOrRelativePath) {
return path_1.resolve(absoluteOrRelativePath);
}
exports.normalizePath = normalizePath;
function maskSecrets(output, env) {
const secret = env["CC_SECRET"];
if (!secret) {
return output;
}
return output.split(secret).join("###");
}
exports.maskSecrets = maskSecrets;
function ensureAbsolutePath(path) {
if (!path_1.isAbsolute(path)) {
throw errors_1.crash(`${path} has to be an absolute path!`);
}
}
exports.ensureAbsolutePath = ensureAbsolutePath;
//# sourceMappingURL=utils.js.map