Skip to content

Commit

Permalink
feat: update naming for config file
Browse files Browse the repository at this point in the history
  • Loading branch information
Renato66 committed May 10, 2024
1 parent 58fca98 commit 7f3ac23
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/auto-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ jobs:
- uses: actions/checkout@v4
with:
sparse-checkout: |
.github/workflows/auto-label.json5
.github/workflows/
# .github/workflows/auto-label.json5
# .github/workflows/auto-label.jsonc
# .github/workflows/auto-label.json
sparse-checkout-cone-mode: false
- uses: Renato66/auto-label@main
with:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/domain/getConfigFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type Config = {
export const getConfigFile = (): Config => {
const configPath = getInput<string>(
'configuration-file',
'.github/workflows/auto-label.json5'
'.github/workflows/'
)
const labelsNotAllowed = getInput<string[]>('labels-not-allowed', [])
const defaultLabels = getInput<string[]>('default-labels', [])
Expand Down
8 changes: 4 additions & 4 deletions src/domain/getLabelConfigs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const defaultConfig = {
describe('getLabelConfigs', () => {
test('should return label configurations from a valid JSON folder path', () => {
const options = [
`${configurationPath}/valid/`,
`${configurationPath}/valid`
`${configurationPath}/`,
`${configurationPath}`
]
options.forEach((elem) => {
const result = getLabelConfigs(elem)
Expand All @@ -24,12 +24,12 @@ describe('getLabelConfigs', () => {
})

test('should return label configurations from a valid JSONC file path', () => {
const result = getLabelConfigs(`${configurationPath}/config.jsonc`)
const result = getLabelConfigs(`${configurationPath}/auto-label.jsonc`)
expect(result).toEqual(defaultConfig)
})

test('should return label configurations from a valid JSON5 file path', () => {
const result = getLabelConfigs(`${configurationPath}/config.json5`)
const result = getLabelConfigs(`${configurationPath}/auto-label.json5`)
expect(result).toEqual(defaultConfig)
})

Expand Down
2 changes: 1 addition & 1 deletion src/domain/getLabelConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const getFilePath = (configurationPath: string): string | undefined => {
return repoPath
if (!configurationPath.includes('.json')) {
const allFiles = fs.readdirSync(repoPath)
const files = allFiles.filter((elem) => jsonTypes.includes(elem))
const files = allFiles.filter((elem) => jsonTypes.map(elem => `auto-label.${elem}`).includes(elem))
if (!files.length) return
return `${repoPath}/${files[0]}`.replace('//', '/')
}
Expand Down

0 comments on commit 7f3ac23

Please sign in to comment.