Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: does not get a complete list because the tree walk works asynchronously #45

Merged
merged 1 commit into from Dec 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 18 additions & 13 deletions index.js
Expand Up @@ -159,19 +159,24 @@ async function main() {

const PROJECT_FILES_TEMP_DIR = path.join(GLCI_DIR, sha);

const tree = await commit.getTree();
const walker = tree.walk();
let projectFiles = [];

// listing .git project files
walker.on("entry", (entry) => {
const path = entry.path();

if (fs.existsSync(path)) {
projectFiles.push(path);
}
});
walker.start();
const projectFiles = await commit.getTree()
.then((tree) => new Promise((resolve, reject) => {
const walker = tree.walk();
const list = [];

// listing .git project files
walker
.on("entry", (entry) => {
const path = entry.path();

if (fs.existsSync(path)) {
list.push(path);
}
})
.on("end", () => resolve(list))
.on("error", (err) => reject(err));
walker.start();
}));

// adding .git to project files
projectFiles.push(".git");
Expand Down