Skip to content

Commit

Permalink
refactor: build app with ncc
Browse files Browse the repository at this point in the history
  • Loading branch information
fabidick22 committed Jun 26, 2022
1 parent e9300b5 commit 44a26cc
Showing 1 changed file with 36 additions and 30 deletions.
66 changes: 36 additions & 30 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8863,41 +8863,47 @@ var __webpack_exports__ = {};
const core = __nccwpck_require__(2186);
const github = __nccwpck_require__(5438);

const main = async () => {
try {
const path = core.getInput('path', { required: true });
const token = core.getInput('token', { required: true });
const regExp = RegExp(path)
const octokit = new github.getOctokit(token);

const response = await octokit.rest.repos.compareCommits({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
base: "HEAD^",
head: "HEAD"
})

const filteredFiles = (response.data.files || []).filter(file => {
let isMatch = regExp.test(file.filename)
console.log(`[${isMatch && '[** match **]'} ${file.filename}`)
console.log(`##Path: ${file.filename} matches`)
return isMatch
async function setOutputs(files) {
const pathsChanged = []
const filesChanged = []
files.forEach(file => {
pathsChanged.push(file.filename.split("/").slice(0, -1).join("/"))
filesChanged.push(file.filename)
})
core.setOutput("paths_changed", JSON.stringify(pathsChanged))
core.setOutput("file_changed", JSON.stringify(filesChanged))
}

if(filteredFiles.length === 0){
console.log("No matchs found.")
console.log(`Raw input: ${directory}`)
console.log(`Regex: ${regExp.toString()}`)
core.setOutput("hasChanges", false)
}
const main = async () => {
try {
const path = core.getInput('path', {required: false}) || "./"
const token = core.getInput('token', {required: true})
const pr = github.context.payload.pull_request
const regExp = RegExp(path)
const octokit = new github.getOctokit(token);

const response = await octokit.rest.pulls.listFiles({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
pull_number: pr.number
})

console.log(`Found a total of ${filteredFiles.length} matches`)
const filteredFiles = (response.data || []).filter(file => {
let isMatch = regExp.test(file.filename)
console.log(`- ${isMatch} [** match **] ${file.filename}`)
return isMatch
})

core.setOutput("hasChanges", true)
if (filteredFiles.length === 0) {
console.log("No matchs found.")
console.log(`Raw input: ${directory}`)
console.log(`Regex: ${regExp.toString()}`)
}
await setOutputs(filteredFiles);

} catch (error) {
core.setFailed(error.message);
}
} catch (error) {
core.setFailed(error.message);
}
}

main();
Expand Down

0 comments on commit 44a26cc

Please sign in to comment.