Skip to content

Commit d76ca69

Browse files
committed
make the exclude file optionally fail when being read with exclude_file_required
1 parent 5074bb1 commit d76ca69

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/functions/exclude.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import ignore from 'ignore'
55
export class Exclude {
66
constructor() {
77
this.path = core.getInput('exclude_file')
8+
this.required = core.getBooleanInput('exclude_file_required')
89
this.gitTrackedOnly = core.getBooleanInput('use_gitignore')
910

1011
// initialize the exclude array
@@ -13,8 +14,17 @@ export class Exclude {
1314
// read the exclude file if it was used
1415
if (this.path && this.path !== '') {
1516
core.debug(`loading exclude_file: ${this.path}`)
16-
this.ignore.add(readFileSync(this.path, 'utf8').toString())
17-
core.debug(`loaded custom exclude patterns`)
17+
try {
18+
this.ignore.add(readFileSync(this.path, 'utf8').toString())
19+
core.debug(`loaded custom exclude patterns`)
20+
} catch (error) {
21+
if (this.required === true) {
22+
core.setFailed(`error reading exclude_file: ${this.path}`)
23+
return new Error(`error: ${error}`)
24+
}
25+
26+
core.info(`exclude_file was not found, but it is not required - OK`)
27+
}
1828
}
1929

2030
// if gitTrackOnly is true, add the git exclude patterns from the .gitignore file if it exists

0 commit comments

Comments
 (0)