Avoid analyzing excluded language files for line counting
This change passes in a list of file types to the line counting analysis. These are the languages for the databases being analyzed. Line count analysis is restricted to these files.
This commit is contained in:
parent
5c0a38d7e4
commit
ee2346270d
31 changed files with 436 additions and 49 deletions
17
node_modules/github-linguist/dist/file.js
generated
vendored
17
node_modules/github-linguist/dist/file.js
generated
vendored
|
|
@ -68,7 +68,7 @@ class LocFile {
|
|||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "language", {
|
||||
Object.defineProperty(this, "languages", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
|
|
@ -147,13 +147,6 @@ class LocFile {
|
|||
this.path = slash2_1.default(rawPath);
|
||||
this.rawPath = rawPath;
|
||||
}
|
||||
/**
|
||||
* get file type through a path
|
||||
*/
|
||||
getType(path) {
|
||||
const fileExtension = `.${path.split('.').pop()}`;
|
||||
return this.language.extensionMap[fileExtension] || '';
|
||||
}
|
||||
/**
|
||||
* Get file info when LocFile init
|
||||
*/
|
||||
|
|
@ -172,12 +165,12 @@ class LocFile {
|
|||
newData = data || await fs.readFile(this.path, 'utf-8');
|
||||
info.name = name;
|
||||
info.size = (stat && stat.size) || 0;
|
||||
info.languages = this.getType(this.path);
|
||||
info.languages = this.languages.getType(this.path);
|
||||
if (!info.languages) {
|
||||
return info;
|
||||
}
|
||||
if (newData) {
|
||||
const regexes = this.language.getRegexes(info.languages);
|
||||
const regexes = this.languages.getRegexes(info.languages);
|
||||
info.lines = this.filterData(newData, regexes);
|
||||
}
|
||||
}
|
||||
|
|
@ -189,8 +182,8 @@ class LocFile {
|
|||
getFileInfoByContent(name, data) {
|
||||
const info = Object.assign({}, DefaultFileInfo);
|
||||
info.name = name;
|
||||
info.languages = this.getType(name);
|
||||
info.lines = this.filterData(data, this.language.getRegexes(info.languages));
|
||||
info.languages = this.languages.getType(name);
|
||||
info.lines = this.filterData(data, this.languages.getRegexes(info.languages));
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue