Skip to content

Commit 5aac6eb

Browse files
committed
chore(deps-dev): upgrade @vercel/ncc to 0.28.x
2 parents 9135e0c + de10324 commit 5aac6eb

File tree

6 files changed

+38
-143
lines changed

6 files changed

+38
-143
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = {
1212
sourceType: 'module'
1313
},
1414
plugins: ['@typescript-eslint'],
15+
ignorePatterns: ['lib/*'],
1516
rules: {
1617
'prettier/prettier': 'warn',
1718
'no-cond-assign': [2, 'except-parens'],

lib/index.js

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 7 additions & 139 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@types/node": "^12.12.54",
4343
"@typescript-eslint/eslint-plugin": "^4.22.0",
4444
"@typescript-eslint/parser": "^4.22.0",
45-
"@vercel/ncc": "^0.27.0",
45+
"@vercel/ncc": "^0.28.3",
4646
"all-contributors-cli": "^6.20.0",
4747
"eslint": "^7.26.0",
4848
"eslint-config-prettier": "^8.3.0",

src/main.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
log,
1010
matchGitArgs,
1111
parseBool,
12+
readJSON,
1213
setOutput,
1314
tools
1415
} from './util'
@@ -186,8 +187,9 @@ async function checkInputs() {
186187
}
187188

188189
const eventPath = process.env.GITHUB_EVENT_PATH,
189-
event = eventPath && require(eventPath),
190-
isPR = process.env.GITHUB_EVENT_NAME?.includes('pull_request'),
190+
event = eventPath && readJSON(eventPath)
191+
192+
const isPR = process.env.GITHUB_EVENT_NAME?.includes('pull_request'),
191193
defaultBranch = isPR
192194
? (event?.pull_request?.head?.ref as string)
193195
: process.env.GITHUB_REF?.substring(11)

src/util.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { parseArgsStringToArgv } from 'string-argv'
22
import * as core from '@actions/core'
33
import { Toolkit } from 'actions-toolkit'
4+
import fs from 'fs'
45

56
export type Input =
67
| 'add'
@@ -98,6 +99,21 @@ export function parseBool(value: any) {
9899
} catch {}
99100
}
100101

102+
export function readJSON(filePath: string) {
103+
let fileContent: string
104+
try {
105+
fileContent = fs.readFileSync(filePath, { encoding: 'utf8' })
106+
} catch {
107+
throw `Couldn't read file. File path: ${filePath}`
108+
}
109+
110+
try {
111+
return JSON.parse(fileContent)
112+
} catch {
113+
throw `Couldn't parse file to JSON. File path: ${filePath}`
114+
}
115+
}
116+
101117
export function setOutput(name: Output, value: 'true' | 'false') {
102118
core.debug(`Setting output: ${name}=${value}`)
103119
tools.outputs[name] = value

0 commit comments

Comments
 (0)