fix: drop require
This commit is contained in:
@@ -12,6 +12,7 @@ module.exports = {
|
|||||||
sourceType: 'module'
|
sourceType: 'module'
|
||||||
},
|
},
|
||||||
plugins: ['@typescript-eslint'],
|
plugins: ['@typescript-eslint'],
|
||||||
|
ignorePatterns: ['lib/*'],
|
||||||
rules: {
|
rules: {
|
||||||
'prettier/prettier': 'warn',
|
'prettier/prettier': 'warn',
|
||||||
'no-cond-assign': [2, 'except-parens'],
|
'no-cond-assign': [2, 'except-parens'],
|
||||||
|
|||||||
37
lib/index.js
generated
37
lib/index.js
generated
@@ -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:
|
/***/ 3129:
|
||||||
@@ -10845,8 +10830,12 @@ var jsYaml = {
|
|||||||
/* harmony default export */ const js_yaml = (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
|
;// CONCATENATED MODULE: ./src/util.ts
|
||||||
|
|
||||||
|
|
||||||
const outputs = {
|
const outputs = {
|
||||||
committed: 'false',
|
committed: 'false',
|
||||||
pushed: 'false',
|
pushed: 'false',
|
||||||
@@ -10881,6 +10870,21 @@ function parseBool(value) {
|
|||||||
}
|
}
|
||||||
catch (_a) { }
|
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) {
|
function setOutput(name, value) {
|
||||||
core.debug(`Setting output: ${name}=${value}`);
|
core.debug(`Setting output: ${name}=${value}`);
|
||||||
outputs[name] = value;
|
outputs[name] = value;
|
||||||
@@ -11045,7 +11049,8 @@ function checkInputs() {
|
|||||||
setInput(input, value);
|
setInput(input, value);
|
||||||
return getInput(input);
|
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
|
? (_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);
|
: (_d = process.env.GITHUB_REF) === null || _d === void 0 ? void 0 : _d.substring(11);
|
||||||
// #region add, remove
|
// #region add, remove
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
matchGitArgs,
|
matchGitArgs,
|
||||||
outputs,
|
outputs,
|
||||||
parseBool,
|
parseBool,
|
||||||
|
readJSON,
|
||||||
setOutput
|
setOutput
|
||||||
} from './util'
|
} from './util'
|
||||||
|
|
||||||
@@ -187,8 +188,9 @@ async function checkInputs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const eventPath = process.env.GITHUB_EVENT_PATH,
|
const eventPath = process.env.GITHUB_EVENT_PATH,
|
||||||
event = eventPath && require(eventPath),
|
event = eventPath && readJSON(eventPath)
|
||||||
isPR = process.env.GITHUB_EVENT_NAME?.includes('pull_request'),
|
|
||||||
|
const isPR = process.env.GITHUB_EVENT_NAME?.includes('pull_request'),
|
||||||
defaultBranch = isPR
|
defaultBranch = isPR
|
||||||
? (event?.pull_request?.head?.ref as string)
|
? (event?.pull_request?.head?.ref as string)
|
||||||
: process.env.GITHUB_REF?.substring(11)
|
: process.env.GITHUB_REF?.substring(11)
|
||||||
|
|||||||
16
src/util.ts
16
src/util.ts
@@ -1,4 +1,5 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
|
import fs from 'fs'
|
||||||
|
|
||||||
export type Input =
|
export type Input =
|
||||||
| 'add'
|
| 'add'
|
||||||
@@ -49,6 +50,21 @@ export function parseBool(value: any) {
|
|||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function readJSON(filePath: string) {
|
||||||
|
let fileContent: string
|
||||||
|
try {
|
||||||
|
fileContent = fs.readFileSync(filePath, { encoding: 'utf8' })
|
||||||
|
} catch {
|
||||||
|
throw `Couldn't read file. File path: ${filePath}`
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return JSON.parse(fileContent)
|
||||||
|
} catch {
|
||||||
|
throw `Couldn't parse file to JSON. File path: ${filePath}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function setOutput(name: Output, value: 'true' | 'false') {
|
export function setOutput(name: Output, value: 'true' | 'false') {
|
||||||
core.debug(`Setting output: ${name}=${value}`)
|
core.debug(`Setting output: ${name}=${value}`)
|
||||||
outputs[name] = value
|
outputs[name] = value
|
||||||
|
|||||||
Reference in New Issue
Block a user