Fix C# line counting and add test
This commit is contained in:
parent
d623a7a3f7
commit
68b68732c6
10 changed files with 86 additions and 24 deletions
26
node_modules/github-linguist/src/languages.ts
generated
vendored
26
node_modules/github-linguist/src/languages.ts
generated
vendored
|
|
@ -11,6 +11,17 @@ interface ExtensionsTypes {
|
|||
|
||||
export interface DetectorOptions {}
|
||||
|
||||
/**
|
||||
* The extension map can contain multiple languages with the same extension,
|
||||
* but we only want a single one. For the moment, these clashes are resolved
|
||||
* by the simple heuristic below listing high-priority languages. We may want
|
||||
* to consider smarter heuristics to correctly identify languages in cases
|
||||
* where the extension is ambiguous. The ordering of the list matters and
|
||||
* languages earlier on will get a higher priority when resolving clashes.
|
||||
*/
|
||||
const importantLanguages = ["javascript", "typescript", "ruby", "python", "java", "c", "c++", "c#", "rust", "scala", "perl", "go"];
|
||||
|
||||
|
||||
/**
|
||||
* detecte program language through file extension
|
||||
*
|
||||
|
|
@ -39,7 +50,20 @@ export class Languages {
|
|||
const languageMode = languageMap[language];
|
||||
const languageExtensions = (languageMode && languageMode.extensions) || [];
|
||||
languageExtensions.forEach((extension: string) => {
|
||||
extensions[extension.toLowerCase()] = language.toLowerCase();
|
||||
const lowerCaseExtension = extension.toLowerCase();
|
||||
const lowerCaseLanguage = language.toLowerCase()
|
||||
if (!extensions[lowerCaseExtension]) {
|
||||
extensions[lowerCaseExtension] = lowerCaseLanguage;
|
||||
} else {
|
||||
const currentLanguagePriority = importantLanguages.indexOf(extensions[lowerCaseExtension]);
|
||||
if (currentLanguagePriority === -1) {
|
||||
extensions[lowerCaseExtension] = lowerCaseLanguage;
|
||||
} else {
|
||||
const otherPriority = importantLanguages.indexOf(lowerCaseLanguage);
|
||||
if (otherPriority !== -1 && otherPriority < currentLanguagePriority)
|
||||
extensions[lowerCaseExtension] = lowerCaseLanguage;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue