From 14885a63d34441264a9040aa05d4929b4501f6f9 Mon Sep 17 00:00:00 2001 From: Donald Wasserman Date: Thu, 5 Dec 2019 15:46:01 -0500 Subject: [PATCH 1/2] Fixed bug that should throw an error but doesn't --- index.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/index.js b/index.js index 3dd0ea3..f761e42 100644 --- a/index.js +++ b/index.js @@ -1,25 +1,25 @@ -const core = require("@actions/core"); +const core = require('@actions/core'); const fs = require('fs'); -const { GitHub } = require("@actions/github"); +const { GitHub } = require('@actions/github'); -const NEWLINE = " \n "; +const NEWLINE = ' \n '; async function run() { - const path = core.getInput("changelog"), - token = core.getInput("token"), + const path = core.getInput('changelog'), + token = core.getInput('token'), ownerRepo = process.env.GITHUB_REPOSITORY, eventPath = process.env.GITHUB_EVENT_PATH, eventName = process.env.GITHUB_EVENT_NAME; - const [owner, repo] = ownerRepo.split("/"); + const [owner, repo] = ownerRepo.split('/'); if (!token) { - core.error("Must provide valid `token` parameter."); + core.error('Must provide valid `token` parameter.'); } const octokit = new GitHub(token); let sha; - let currentContents = ""; + let currentContents = ''; let changelogExists = true; try { @@ -29,24 +29,24 @@ async function run() { path }); - if (data.type !== "file") { + if (data.type !== 'file') { core.error(`Your specified changelog ${path}, is not a file`); } if (data.sha) { sha = data.sha; } - currentContents = `${data.contents} ${NEWLINE}`; - } catch(e) { + console.log(data.content); + currentContents = `${data.content} ${NEWLINE}`; + } catch (e) { changelogExists = false; } - let { url, tag, name, body } = getReleaseData(eventPath); currentContents += `### [${name}](${url}) ${NEWLINE} **${tag}** ${NEWLINE} ${body}`; let buff = new Buffer.from(currentContents); - let content = buff.toString("base64"); + let content = buff.toString('base64'); let options = { owner, @@ -68,7 +68,7 @@ async function run() { } function getReleaseData(eventPath) { - const event = JSON.parse(fs.readFileSync(eventPath, "utf8")); + const event = JSON.parse(fs.readFileSync(eventPath, 'utf8')); let { html_url: url, tag_name: tag, name, body } = event.release; From e8cfe2c2657294e111b84a076f8e8650613d56ed Mon Sep 17 00:00:00 2001 From: Donald Wasserman Date: Thu, 5 Dec 2019 15:48:43 -0500 Subject: [PATCH 2/2] Updated build script --- dist/index.js | 24 ++++++++++++------------ package.json | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/dist/index.js b/dist/index.js index d21e9da..876daca 100644 --- a/dist/index.js +++ b/dist/index.js @@ -496,24 +496,24 @@ const core = __webpack_require__(470); const fs = __webpack_require__(747); const { GitHub } = __webpack_require__(469); -const NEWLINE = " \n "; +const NEWLINE = ' \n '; async function run() { - const path = core.getInput("changelog"), - token = core.getInput("token"), + const path = core.getInput('changelog'), + token = core.getInput('token'), ownerRepo = process.env.GITHUB_REPOSITORY, eventPath = process.env.GITHUB_EVENT_PATH, eventName = process.env.GITHUB_EVENT_NAME; - const [owner, repo] = ownerRepo.split("/"); + const [owner, repo] = ownerRepo.split('/'); if (!token) { - core.error("Must provide valid `token` parameter."); + core.error('Must provide valid `token` parameter.'); } const octokit = new GitHub(token); let sha; - let currentContents = ""; + let currentContents = ''; let changelogExists = true; try { @@ -523,24 +523,24 @@ async function run() { path }); - if (data.type !== "file") { + if (data.type !== 'file') { core.error(`Your specified changelog ${path}, is not a file`); } if (data.sha) { sha = data.sha; } - currentContents = `${data.contents} ${NEWLINE}`; - } catch(e) { + console.log(data.content); + currentContents = `${data.content} ${NEWLINE}`; + } catch (e) { changelogExists = false; } - let { url, tag, name, body } = getReleaseData(eventPath); currentContents += `### [${name}](${url}) ${NEWLINE} **${tag}** ${NEWLINE} ${body}`; let buff = new Buffer.from(currentContents); - let content = buff.toString("base64"); + let content = buff.toString('base64'); let options = { owner, @@ -562,7 +562,7 @@ async function run() { } function getReleaseData(eventPath) { - const event = JSON.parse(fs.readFileSync(eventPath, "utf8")); + const event = JSON.parse(fs.readFileSync(eventPath, 'utf8')); let { html_url: url, tag_name: tag, name, body } = event.release; diff --git a/package.json b/package.json index 6ae0d3a..94d49b8 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ }, "husky": { "hooks": { - "pre-commit": "lint-staged && yarn build" + "pre-commit": "lint-staged && yarn build && git add ." } } }