Skip to content

Commit

Permalink
skip yaml files in the json validator if yamlAsJson === false
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBirki committed Dec 29, 2023
1 parent 42f2e19 commit fc0274e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
12 changes: 12 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions src/functions/json-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@ export async function jsonValidator(exclude) {
) {
core.debug(`attempting to process yaml file: '${fullPath}' as json`)
data = parse(readFileSync(fullPath, 'utf8'))

// if the file is a yaml file but it should not be treated as json
} else if (
yamlAsJson === false &&
(fullPath.endsWith(yamlExtension) ||
fullPath.endsWith(yamlExtensionShort))
) {
core.debug(
`the json-validator found a yaml file so it will be skipped here: '${fullPath}'`
)
continue

// if the file is a json file
} else {
data = JSON.parse(readFileSync(fullPath, 'utf8'))
Expand Down

0 comments on commit fc0274e

Please sign in to comment.