Skip to content

Commit 9dae423

Browse files
authored
Merge pull request #25 from GrantBirki/debug-improvements
debug improvements
2 parents 4dc9717 + 365fb47 commit 9dae423

File tree

6 files changed

+47
-18
lines changed

6 files changed

+47
-18
lines changed

__tests__/functions/exclude.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ test('does not exclude any files when no exclude file is used', () => {
7676
process.env.INPUT_USE_GITIGNORE = 'false'
7777
const exclude = new Exclude()
7878
expect(exclude.isExcluded('exclude-me.json')).toBe(false)
79-
expect(debugMock).not.toHaveBeenCalled()
8079
})
8180

8281
test('excludes a file that is not tracked by git', () => {

dist/index.js

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

dist/index.js.map

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

src/functions/exclude.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,25 @@ export class Exclude {
1111

1212
// read the exclude file if it was used
1313
if (this.path && this.path !== '') {
14+
core.debug(`loading exclude_file: ${this.path}`)
15+
1416
this.exclude = readFileSync(this.path, 'utf8')
1517
// split the exclude file into an array of strings and trim each string
1618
this.exclude = this.exclude.split('\n').map(item => item.trim())
1719
// remove any empty strings
1820
this.exclude = this.exclude.filter(item => item !== '')
1921
// remove any comments
2022
this.exclude = this.exclude.filter(item => !item.startsWith('#'))
23+
24+
core.debug(`loaded exclude patterns: ${this.exclude}`)
2125
}
2226

2327
// if gitTrackOnly is true, add the git exclude patterns from the .gitignore file if it exists
2428
if (this.gitTrackedOnly) {
29+
core.debug(
30+
`use_gitignore: ${this.gitTrackedOnly} - only using git tracked files`
31+
)
32+
2533
const gitIgnorePath = core.getInput('git_ignore_path')
2634
var gitIgnoreExclude = []
2735
try {

src/functions/json-validator.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,14 @@ export async function jsonValidator(exclude) {
7676
? `**/*{${jsonExtension},${yamlGlob}}`
7777
: `**/*${jsonExtension}`
7878

79+
core.debug(`using baseDir: ${baseDirSanitized}`)
80+
core.debug(`using glob: ${glob}`)
81+
7982
const files = globSync(glob, {cwd: baseDirSanitized, dot: useDotMatch})
8083
for (const file of files) {
8184
// construct the full path to the file
8285
const fullPath = `${baseDirSanitized}/${file}`
86+
core.debug(`found file: ${fullPath}`)
8387

8488
if (jsonSchema !== '' && fullPath.includes(jsonSchema)) {
8589
// skip the jsonSchema file and don't count it as a skipped file
@@ -103,7 +107,6 @@ export async function jsonValidator(exclude) {
103107
}
104108

105109
var data
106-
107110
try {
108111
// try to parse the file
109112
if (fullPath.endsWith('.yaml')) {

src/functions/yaml-validator.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,20 @@ export async function yamlValidator(exclude) {
3131
skipped: 0,
3232
violations: []
3333
}
34-
const files = globSync(
35-
`**/*.{${yamlExtension.replace('.', '')},${yamlExtensionShort.replace(
36-
'.',
37-
''
38-
)}}`,
39-
{cwd: baseDirSanitized, dot: useDotMatch}
40-
)
34+
35+
const glob = `**/*.{${yamlExtension.replace(
36+
'.',
37+
''
38+
)},${yamlExtensionShort.replace('.', '')}}`
39+
40+
core.debug(`using baseDir: ${baseDirSanitized}`)
41+
core.debug(`using glob: ${glob}`)
42+
43+
const files = globSync(glob, {cwd: baseDirSanitized, dot: useDotMatch})
4144
for (const file of files) {
4245
// construct the full path to the file
4346
const fullPath = `${baseDirSanitized}/${file}`
47+
core.debug(`found file: ${fullPath}`)
4448

4549
if (yamlSchema !== '' && fullPath.includes(yamlSchema)) {
4650
core.debug(`skipping yaml schema file: ${fullPath}`)

0 commit comments

Comments
 (0)