Skip to content

Commit

Permalink
feat: update json5 to be ignored by prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Renato66 committed May 8, 2024
1 parent a528db7 commit 463a660
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/auto-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Labeling new issue

on:
issues:
types: ['opened']
types: ['opened']
jobs:
build:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
auto-label.json5
14 changes: 8 additions & 6 deletions src/domain/getConfigFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ import { getInput } from './getInput'
import { getLabelConfigs } from './getJsonFile'

export type Config = {
labelsNotAllowed: string[];
defaultLabels: string[];
labelsSynonyms: Record<string, string[]>;
ignoreComments: boolean;
labelsNotAllowed: string[]
defaultLabels: string[]
labelsSynonyms: Record<string, string[]>
ignoreComments: boolean
}

export const getConfigFile = (): Config => {

const configPath = getInput<string>('configuration-file', '.github/workflows/auto-label.json5')
const configPath = getInput<string>(
'configuration-file',
'.github/workflows/auto-label.json5'
)
const labelsNotAllowed = getInput<string[]>('labels-not-allowed', [])
const defaultLabels = getInput<string[]>('default-labels', [])
const labelsSynonyms = getInput<Record<string, string[]>>(
Expand Down
22 changes: 16 additions & 6 deletions src/domain/getJsonFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,23 @@ export const getLabelConfigs = (configurationPath: string): Config | {} => {
})

try {
const config =
JSON5.parse(fileContent)
const config = JSON5.parse(fileContent)
return {
defaultLabels: Array.isArray(config.defaultLabels) ? config.defaultLabels : undefined,
labelsNotAllowed: Array.isArray(config.labelsNotAllowed) ? config.labelsNotAllowed : undefined,
ignoreComments: typeof config.ignoreComments === 'boolean' ? config.ignoreComments : undefined,
labelsSynonyms: typeof config.labelsSynonyms === 'object' && !Array.isArray(config.labelsSynonyms) ? config.labelsSynonyms : undefined
defaultLabels: Array.isArray(config.defaultLabels)
? config.defaultLabels
: undefined,
labelsNotAllowed: Array.isArray(config.labelsNotAllowed)
? config.labelsNotAllowed
: undefined,
ignoreComments:
typeof config.ignoreComments === 'boolean'
? config.ignoreComments
: undefined,
labelsSynonyms:
typeof config.labelsSynonyms === 'object' &&
!Array.isArray(config.labelsSynonyms)
? config.labelsSynonyms
: undefined
}
} catch {
core.warning('Could not parse configuration file. skipping')
Expand Down

0 comments on commit 463a660

Please sign in to comment.