Skip to content

Commit 44a26cc

Browse files
committed
refactor: build app with ncc
1 parent e9300b5 commit 44a26cc

File tree

1 file changed

+36
-30
lines changed

1 file changed

+36
-30
lines changed

dist/index.js

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8863,41 +8863,47 @@ var __webpack_exports__ = {};
88638863
const core = __nccwpck_require__(2186);
88648864
const github = __nccwpck_require__(5438);
88658865

8866-
const main = async () => {
8867-
try {
8868-
const path = core.getInput('path', { required: true });
8869-
const token = core.getInput('token', { required: true });
8870-
const regExp = RegExp(path)
8871-
const octokit = new github.getOctokit(token);
8872-
8873-
const response = await octokit.rest.repos.compareCommits({
8874-
owner: github.context.repo.owner,
8875-
repo: github.context.repo.repo,
8876-
base: "HEAD^",
8877-
head: "HEAD"
8878-
})
8879-
8880-
const filteredFiles = (response.data.files || []).filter(file => {
8881-
let isMatch = regExp.test(file.filename)
8882-
console.log(`[${isMatch && '[** match **]'} ${file.filename}`)
8883-
console.log(`##Path: ${file.filename} matches`)
8884-
return isMatch
8866+
async function setOutputs(files) {
8867+
const pathsChanged = []
8868+
const filesChanged = []
8869+
files.forEach(file => {
8870+
pathsChanged.push(file.filename.split("/").slice(0, -1).join("/"))
8871+
filesChanged.push(file.filename)
88858872
})
8873+
core.setOutput("paths_changed", JSON.stringify(pathsChanged))
8874+
core.setOutput("file_changed", JSON.stringify(filesChanged))
8875+
}
88868876

8887-
if(filteredFiles.length === 0){
8888-
console.log("No matchs found.")
8889-
console.log(`Raw input: ${directory}`)
8890-
console.log(`Regex: ${regExp.toString()}`)
8891-
core.setOutput("hasChanges", false)
8892-
}
8877+
const main = async () => {
8878+
try {
8879+
const path = core.getInput('path', {required: false}) || "./"
8880+
const token = core.getInput('token', {required: true})
8881+
const pr = github.context.payload.pull_request
8882+
const regExp = RegExp(path)
8883+
const octokit = new github.getOctokit(token);
8884+
8885+
const response = await octokit.rest.pulls.listFiles({
8886+
owner: github.context.repo.owner,
8887+
repo: github.context.repo.repo,
8888+
pull_number: pr.number
8889+
})
88938890

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

8896-
core.setOutput("hasChanges", true)
8897+
if (filteredFiles.length === 0) {
8898+
console.log("No matchs found.")
8899+
console.log(`Raw input: ${directory}`)
8900+
console.log(`Regex: ${regExp.toString()}`)
8901+
}
8902+
await setOutputs(filteredFiles);
88978903

8898-
} catch (error) {
8899-
core.setFailed(error.message);
8900-
}
8904+
} catch (error) {
8905+
core.setFailed(error.message);
8906+
}
89018907
}
89028908

89038909
main();

0 commit comments

Comments
 (0)