mirror of
https://github.com/github/codeql-action.git
synced 2026-01-02 20:50:05 +08:00
Update loc count library
This version will count lines of code in each file serially. It still runs all file system operations asynchronously. The only difference now is that it will only count one file at a time. It is slower, but it is able to count large repositories without running out of memory.
This commit is contained in:
8
node_modules/github-linguist/src/directory.ts
generated
vendored
8
node_modules/github-linguist/src/directory.ts
generated
vendored
@@ -166,7 +166,9 @@ export class LocDir {
|
||||
};
|
||||
} = {};
|
||||
|
||||
await Promise.all(paths.map(async (pathItem) => {
|
||||
// We _could_ use Promise.all to count the files in parallel, but that
|
||||
// would lead to out of memory errors when there are many files.
|
||||
for (const pathItem of paths) {
|
||||
const fullPath = slash(path.join(this.cwd, pathItem));
|
||||
if (
|
||||
!pathItem ||
|
||||
@@ -174,7 +176,7 @@ export class LocDir {
|
||||
!(await fs.pathExists(fullPath)) ||
|
||||
(await fs.stat(fullPath)).isDirectory()
|
||||
) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
const file = new LocFile(fullPath);
|
||||
const fileLineInfo = await file.getFileInfo();
|
||||
@@ -192,7 +194,7 @@ export class LocDir {
|
||||
[fileLineInfo.languages]: language,
|
||||
};
|
||||
files.push(fullPath);
|
||||
}));
|
||||
}
|
||||
|
||||
return {
|
||||
files,
|
||||
|
||||
Reference in New Issue
Block a user