Skip to content

Commit cd89533

Browse files
authored
Update action.js
1 parent 08f3eef commit cd89533

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

action.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ const unsupportedEvent = name => name !== "pull_request" && name !== "push" ? tr
55
const getBase = name => data => name === "pull_request" ? data.pull_request.base.sha : data.before;
66
const getHead = name => data => name === "pull_request" ? data.pull_request.head.sha : data.after;
77
const normalise = path => path.split("/").filter(item => item !== "" && item !== ".").join("/");
8-
const failed = massage => { throw message; };
8+
const toBoolean = value => value.toLowerCase() == "true";
99

1010
(async function(){
1111
try {
1212
const path = core.getInput("path");
1313
const token = core.getInput("token");
14-
const strict = core.getInput("strict");
1514
const repo = github.context.repo.repo;
1615
const owner = github.context.repo.owner;
1716
const event_name = github.context.eventName;
17+
const strict = toBoolean(core.getInput("strict"));
1818
const octokit = github.getOctokit(token, { required: true });
1919

2020
if (unsupportedEvent(event_name)) throw `This event (${event_name}) is unsupported. Simple Diff only supports PUSH and PR events.`;
@@ -39,9 +39,8 @@ const failed = massage => { throw message; };
3939
return;
4040
}
4141

42-
strict === true
43-
? failed(`None of the files in this commits diff tree match the provided file (${path}).`)
44-
: console.log(`None of the files in this commits diff tree match the provided file (${path}).`);
42+
if (strict === true) throw `None of the files in this commits diff tree match the provided file (${path}).`;
43+
console.log(`None of the files in this commits diff tree match the provided file (${path}).`);
4544

4645
} catch (error) {
4746
core.setFailed(error);

0 commit comments

Comments
 (0)