Skip to content

Commit 7eb6ada

Browse files
authored
Convert to ES6.
1 parent e16f916 commit 7eb6ada

File tree

2 files changed

+83
-43
lines changed

2 files changed

+83
-43
lines changed

dist/index.js

Lines changed: 66 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7610,31 +7610,79 @@ module.exports = require("zlib");
76107610
/******/ }
76117611
/******/
76127612
/************************************************************************/
7613+
/******/ /* webpack/runtime/compat get default export */
7614+
/******/ (() => {
7615+
/******/ // getDefaultExport function for compatibility with non-harmony modules
7616+
/******/ __nccwpck_require__.n = (module) => {
7617+
/******/ var getter = module && module.__esModule ?
7618+
/******/ () => (module['default']) :
7619+
/******/ () => (module);
7620+
/******/ __nccwpck_require__.d(getter, { a: getter });
7621+
/******/ return getter;
7622+
/******/ };
7623+
/******/ })();
7624+
/******/
7625+
/******/ /* webpack/runtime/define property getters */
7626+
/******/ (() => {
7627+
/******/ // define getter functions for harmony exports
7628+
/******/ __nccwpck_require__.d = (exports, definition) => {
7629+
/******/ for(var key in definition) {
7630+
/******/ if(__nccwpck_require__.o(definition, key) && !__nccwpck_require__.o(exports, key)) {
7631+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
7632+
/******/ }
7633+
/******/ }
7634+
/******/ };
7635+
/******/ })();
7636+
/******/
7637+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
7638+
/******/ (() => {
7639+
/******/ __nccwpck_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
7640+
/******/ })();
7641+
/******/
7642+
/******/ /* webpack/runtime/make namespace object */
7643+
/******/ (() => {
7644+
/******/ // define __esModule on exports
7645+
/******/ __nccwpck_require__.r = (exports) => {
7646+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
7647+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
7648+
/******/ }
7649+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
7650+
/******/ };
7651+
/******/ })();
7652+
/******/
76137653
/******/ /* webpack/runtime/compat */
76147654
/******/
76157655
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
76167656
/******/
76177657
/************************************************************************/
76187658
var __webpack_exports__ = {};
7619-
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
7659+
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
76207660
(() => {
7621-
const core = __nccwpck_require__(2186)
7622-
const exec = __nccwpck_require__(1514)
7623-
const github = __nccwpck_require__(5438)
7661+
"use strict";
7662+
__nccwpck_require__.r(__webpack_exports__);
7663+
/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(2186);
7664+
/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(_actions_core__WEBPACK_IMPORTED_MODULE_0__);
7665+
/* harmony import */ var _actions_exec__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(1514);
7666+
/* harmony import */ var _actions_exec__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__nccwpck_require__.n(_actions_exec__WEBPACK_IMPORTED_MODULE_1__);
7667+
/* harmony import */ var _actions_github__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(5438);
7668+
/* harmony import */ var _actions_github__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__nccwpck_require__.n(_actions_github__WEBPACK_IMPORTED_MODULE_2__);
7669+
7670+
7671+
76247672

76257673
const src = __dirname
76267674

76277675
async function run() {
76287676
try {
7629-
var headRef = core.getInput('head-ref')
7630-
var baseRef = core.getInput('base-ref')
7631-
const myToken = core.getInput('myToken')
7632-
const octokit = new github.getOctokit(myToken)
7633-
const { owner, repo } = github.context.repo
7677+
var headRef = (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('head-ref')
7678+
var baseRef = (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('base-ref')
7679+
const myToken = (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('myToken')
7680+
const octokit = new _actions_github__WEBPACK_IMPORTED_MODULE_2__.getOctokit(myToken)
7681+
const { owner, repo } = _actions_github__WEBPACK_IMPORTED_MODULE_2__.context.repo
76347682
const regexp = /^[.A-Za-z0-9_-]*$/
76357683

76367684
if (!headRef) {
7637-
headRef = github.context.sha
7685+
headRef = _actions_github__WEBPACK_IMPORTED_MODULE_2__.context.sha
76387686
}
76397687

76407688
if (!baseRef) {
@@ -7645,7 +7693,7 @@ async function run() {
76457693
if (latestRelease) {
76467694
baseRef = latestRelease.data.tag_name
76477695
} else {
7648-
core.setFailed(
7696+
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed)(
76497697
`There are no releases on ${owner}/${repo}. Tags are not releases.`
76507698
)
76517699
}
@@ -7662,12 +7710,12 @@ async function run() {
76627710
) {
76637711
getChangelog(headRef, baseRef, owner + '/' + repo)
76647712
} else {
7665-
core.setFailed(
7713+
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed)(
76667714
'Branch names must contain only numbers, strings, underscores, periods, and dashes.'
76677715
)
76687716
}
76697717
} catch (error) {
7670-
core.setFailed(error.message)
7718+
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed)(error.message)
76717719
}
76727720
}
76737721

@@ -7688,24 +7736,20 @@ async function getChangelog(headRef, baseRef, repoName) {
76887736
}
76897737
options.cwd = './'
76907738

7691-
await exec.exec(
7692-
__nccwpck_require__.ab + "changelog.sh",
7693-
[headRef, baseRef, repoName],
7694-
options
7695-
)
7739+
await (0,_actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec)(__nccwpck_require__.ab + "changelog.sh", [headRef, baseRef, repoName], options)
76967740

76977741
if (output) {
76987742
console.log(
76997743
'\x1b[32m%s\x1b[0m',
77007744
`Changelog between ${baseRef} and ${headRef}:\n${output}`
77017745
)
7702-
core.setOutput('changelog', output)
7746+
;(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.setOutput)('changelog', output)
77037747
} else {
7704-
core.setFailed(err)
7748+
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed)(err)
77057749
process.exit(1)
77067750
}
77077751
} catch (err) {
7708-
core.setFailed(
7752+
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed)(
77097753
`Could not generate changelog between references because: ${err.message}`
77107754
)
77117755
process.exit(0)
@@ -7715,7 +7759,7 @@ async function getChangelog(headRef, baseRef, repoName) {
77157759
try {
77167760
run()
77177761
} catch (error) {
7718-
core.setFailed(error.message)
7762+
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed)(error.message)
77197763
}
77207764

77217765
})();

index.js

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
const core = require('@actions/core')
2-
const exec = require('@actions/exec')
3-
const github = require('@actions/github')
1+
import { getInput, setFailed, setOutput } from '@actions/core'
2+
import { exec as _exec } from '@actions/exec'
3+
import { getOctokit, context } from '@actions/github'
44

55
const src = __dirname
66

77
async function run() {
88
try {
9-
var headRef = core.getInput('head-ref')
10-
var baseRef = core.getInput('base-ref')
11-
const myToken = core.getInput('myToken')
12-
const octokit = new github.getOctokit(myToken)
13-
const { owner, repo } = github.context.repo
9+
var headRef = getInput('head-ref')
10+
var baseRef = getInput('base-ref')
11+
const myToken = getInput('myToken')
12+
const octokit = new getOctokit(myToken)
13+
const { owner, repo } = context.repo
1414
const regexp = /^[.A-Za-z0-9_-]*$/
1515

1616
if (!headRef) {
17-
headRef = github.context.sha
17+
headRef = context.sha
1818
}
1919

2020
if (!baseRef) {
@@ -25,7 +25,7 @@ async function run() {
2525
if (latestRelease) {
2626
baseRef = latestRelease.data.tag_name
2727
} else {
28-
core.setFailed(
28+
setFailed(
2929
`There are no releases on ${owner}/${repo}. Tags are not releases.`
3030
)
3131
}
@@ -42,12 +42,12 @@ async function run() {
4242
) {
4343
getChangelog(headRef, baseRef, owner + '/' + repo)
4444
} else {
45-
core.setFailed(
45+
setFailed(
4646
'Branch names must contain only numbers, strings, underscores, periods, and dashes.'
4747
)
4848
}
4949
} catch (error) {
50-
core.setFailed(error.message)
50+
setFailed(error.message)
5151
}
5252
}
5353

@@ -68,24 +68,20 @@ async function getChangelog(headRef, baseRef, repoName) {
6868
}
6969
options.cwd = './'
7070

71-
await exec.exec(
72-
`${src}/changelog.sh`,
73-
[headRef, baseRef, repoName],
74-
options
75-
)
71+
await _exec(`${src}/changelog.sh`, [headRef, baseRef, repoName], options)
7672

7773
if (output) {
7874
console.log(
7975
'\x1b[32m%s\x1b[0m',
8076
`Changelog between ${baseRef} and ${headRef}:\n${output}`
8177
)
82-
core.setOutput('changelog', output)
78+
setOutput('changelog', output)
8379
} else {
84-
core.setFailed(err)
80+
setFailed(err)
8581
process.exit(1)
8682
}
8783
} catch (err) {
88-
core.setFailed(
84+
setFailed(
8985
`Could not generate changelog between references because: ${err.message}`
9086
)
9187
process.exit(0)
@@ -95,5 +91,5 @@ async function getChangelog(headRef, baseRef, repoName) {
9591
try {
9692
run()
9793
} catch (error) {
98-
core.setFailed(error.message)
94+
setFailed(error.message)
9995
}

0 commit comments

Comments
 (0)