fix: drop require

This commit is contained in:
Federico Grandi
2021-05-06 10:28:43 +02:00
parent 724766a764
commit 245f959e32
4 changed files with 42 additions and 18 deletions

37
lib/index.js generated
View File

@@ -6855,21 +6855,6 @@ module.exports = {
};
/***/ }),
/***/ 875:
/***/ ((module) => {
function webpackEmptyContext(req) {
var e = new Error("Cannot find module '" + req + "'");
e.code = 'MODULE_NOT_FOUND';
throw e;
}
webpackEmptyContext.keys = () => ([]);
webpackEmptyContext.resolve = webpackEmptyContext;
webpackEmptyContext.id = 875;
module.exports = webpackEmptyContext;
/***/ }),
/***/ 3129:
@@ -10845,8 +10830,12 @@ var jsYaml = {
/* harmony default export */ const js_yaml = (jsYaml);
// EXTERNAL MODULE: external "fs"
var external_fs_ = __nccwpck_require__(5747);
var external_fs_default = /*#__PURE__*/__nccwpck_require__.n(external_fs_);
;// CONCATENATED MODULE: ./src/util.ts
const outputs = {
committed: 'false',
pushed: 'false',
@@ -10881,6 +10870,21 @@ function parseBool(value) {
}
catch (_a) { }
}
function readJSON(filePath) {
let fileContent;
try {
fileContent = external_fs_default().readFileSync(filePath, { encoding: 'utf8' });
}
catch (_a) {
throw `Couldn't read file. File path: ${filePath}`;
}
try {
return JSON.parse(fileContent);
}
catch (_b) {
throw `Couldn't parse file to JSON. File path: ${filePath}`;
}
}
function setOutput(name, value) {
core.debug(`Setting output: ${name}=${value}`);
outputs[name] = value;
@@ -11045,7 +11049,8 @@ function checkInputs() {
setInput(input, value);
return getInput(input);
}
const eventPath = process.env.GITHUB_EVENT_PATH, event = eventPath && __nccwpck_require__(875)(eventPath), isPR = (_a = process.env.GITHUB_EVENT_NAME) === null || _a === void 0 ? void 0 : _a.includes('pull_request'), defaultBranch = isPR
const eventPath = process.env.GITHUB_EVENT_PATH, event = eventPath && readJSON(eventPath);
const isPR = (_a = process.env.GITHUB_EVENT_NAME) === null || _a === void 0 ? void 0 : _a.includes('pull_request'), defaultBranch = isPR
? (_c = (_b = event === null || event === void 0 ? void 0 : event.pull_request) === null || _b === void 0 ? void 0 : _b.head) === null || _c === void 0 ? void 0 : _c.ref
: (_d = process.env.GITHUB_REF) === null || _d === void 0 ? void 0 : _d.substring(11);
// #region add, remove