Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/only-package-commits.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ const getPackagePath = async () => {
};

const withFiles = async commits => {
// Handle case where commits is null, undefined, or not an array
if (!commits || !Array.isArray(commits) || commits.length === 0) {
return {
// Return an empty array of commits with no files
commits: [],
files: []
}
}

const limit = pLimit(Number(process.env.SRM_MAX_THREADS) || 500);
return Promise.all(
commits.map(commit =>
Expand All @@ -33,6 +42,15 @@ const withFiles = async commits => {
};

const onlyPackageCommits = async commits => {
// Handle case where commits is null, undefined, or not an array
if (!commits || !Array.isArray(commits) || commits.length === 0) {
return {
// Return an empty array of commits with no files
commits: [],
files: []
};
}

const packagePath = await getPackagePath();
debug('Filter commits by package path: "%s"', packagePath);
const commitsWithFiles = await withFiles(commits);
Expand Down