Skip to content

Commit

Permalink
Convert to ES6.
Browse files Browse the repository at this point in the history
  • Loading branch information
metcalfc committed Oct 13, 2021
1 parent e16f916 commit 597c7c4
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 43 deletions.
88 changes: 66 additions & 22 deletions dist/index.js
Expand Up @@ -7610,31 +7610,79 @@ module.exports = require("zlib");
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ (() => {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __nccwpck_require__.n = (module) => {
/******/ var getter = module && module.__esModule ?
/******/ () => (module['default']) :
/******/ () => (module);
/******/ __nccwpck_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __nccwpck_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__nccwpck_require__.o(definition, key) && !__nccwpck_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __nccwpck_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __nccwpck_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/compat */
/******/
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
(() => {
const core = __nccwpck_require__(2186)
const exec = __nccwpck_require__(1514)
const github = __nccwpck_require__(5438)
"use strict";
__nccwpck_require__.r(__webpack_exports__);
/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(2186);
/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(_actions_core__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _actions_exec__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(1514);
/* harmony import */ var _actions_exec__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__nccwpck_require__.n(_actions_exec__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _actions_github__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(5438);
/* harmony import */ var _actions_github__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__nccwpck_require__.n(_actions_github__WEBPACK_IMPORTED_MODULE_2__);




const src = __dirname

async function run() {
try {
var headRef = core.getInput('head-ref')
var baseRef = core.getInput('base-ref')
const myToken = core.getInput('myToken')
const octokit = new github.getOctokit(myToken)
const { owner, repo } = github.context.repo
var headRef = (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('head-ref')
var baseRef = (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('base-ref')
const myToken = (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('myToken')
const octokit = new _actions_github__WEBPACK_IMPORTED_MODULE_2__.getOctokit(myToken)
const { owner, repo } = _actions_github__WEBPACK_IMPORTED_MODULE_2__.context.repo
const regexp = /^[.A-Za-z0-9_-]*$/

if (!headRef) {
headRef = github.context.sha
headRef = _actions_github__WEBPACK_IMPORTED_MODULE_2__.context.sha
}

if (!baseRef) {
Expand All @@ -7645,7 +7693,7 @@ async function run() {
if (latestRelease) {
baseRef = latestRelease.data.tag_name
} else {
core.setFailed(
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed)(
`There are no releases on ${owner}/${repo}. Tags are not releases.`
)
}
Expand All @@ -7662,12 +7710,12 @@ async function run() {
) {
getChangelog(headRef, baseRef, owner + '/' + repo)
} else {
core.setFailed(
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed)(
'Branch names must contain only numbers, strings, underscores, periods, and dashes.'
)
}
} catch (error) {
core.setFailed(error.message)
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed)(error.message)
}
}

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

await exec.exec(
__nccwpck_require__.ab + "changelog.sh",
[headRef, baseRef, repoName],
options
)
await (0,_actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec)(__nccwpck_require__.ab + "changelog.sh", [headRef, baseRef, repoName], options)

if (output) {
console.log(
'\x1b[32m%s\x1b[0m',
`Changelog between ${baseRef} and ${headRef}:\n${output}`
)
core.setOutput('changelog', output)
;(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.setOutput)('changelog', output)
} else {
core.setFailed(err)
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed)(err)
process.exit(1)
}
} catch (err) {
core.setFailed(
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed)(
`Could not generate changelog between references because: ${err.message}`
)
process.exit(0)
Expand All @@ -7715,7 +7759,7 @@ async function getChangelog(headRef, baseRef, repoName) {
try {
run()
} catch (error) {
core.setFailed(error.message)
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed)(error.message)
}

})();
Expand Down
38 changes: 17 additions & 21 deletions index.js
@@ -1,20 +1,20 @@
const core = require('@actions/core')
const exec = require('@actions/exec')
const github = require('@actions/github')
import { getInput, setFailed, setOutput } from '@actions/core'
import { exec as _exec } from '@actions/exec'
import { getOctokit, context } from '@actions/github'

const src = __dirname

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

if (!headRef) {
headRef = github.context.sha
headRef = context.sha
}

if (!baseRef) {
Expand All @@ -25,7 +25,7 @@ async function run() {
if (latestRelease) {
baseRef = latestRelease.data.tag_name
} else {
core.setFailed(
setFailed(
`There are no releases on ${owner}/${repo}. Tags are not releases.`
)
}
Expand All @@ -42,12 +42,12 @@ async function run() {
) {
getChangelog(headRef, baseRef, owner + '/' + repo)
} else {
core.setFailed(
setFailed(
'Branch names must contain only numbers, strings, underscores, periods, and dashes.'
)
}
} catch (error) {
core.setFailed(error.message)
setFailed(error.message)
}
}

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

await exec.exec(
`${src}/changelog.sh`,
[headRef, baseRef, repoName],
options
)
await _exec(`${src}/changelog.sh`, [headRef, baseRef, repoName], options)

if (output) {
console.log(
'\x1b[32m%s\x1b[0m',
`Changelog between ${baseRef} and ${headRef}:\n${output}`
)
core.setOutput('changelog', output)
setOutput('changelog', output)
} else {
core.setFailed(err)
setFailed(err)
process.exit(1)
}
} catch (err) {
core.setFailed(
setFailed(
`Could not generate changelog between references because: ${err.message}`
)
process.exit(0)
Expand All @@ -95,5 +91,5 @@ async function getChangelog(headRef, baseRef, repoName) {
try {
run()
} catch (error) {
core.setFailed(error.message)
setFailed(error.message)
}

0 comments on commit 597c7c4

Please sign in to comment.