linguist-js 2.5.4 → 2.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers/convert-pcre.js +5 -4
- package/dist/helpers/load-data.js +2 -1
- package/dist/schema.d.ts +1 -1
- package/dist/types.d.ts +6 -6
- package/ext/documentation.yml +1 -1
- package/ext/generated.rb +5 -1
- package/ext/heuristics.yml +804 -771
- package/ext/languages.yml +272 -35
- package/ext/vendor.yml +4 -2
- package/package.json +7 -7
- package/readme.md +3 -2
|
@@ -6,11 +6,12 @@ function pcre(regex) {
|
|
|
6
6
|
const replace = (search, replace) => finalRegex = finalRegex.replace(search, replace);
|
|
7
7
|
const finalFlags = new Set();
|
|
8
8
|
// Convert inline flag declarations
|
|
9
|
-
const inlineMatches = regex.matchAll(/\?([a-z]):/g);
|
|
10
|
-
const startMatches = regex.matchAll(/\(\?([a-z]+)\)/g);
|
|
11
|
-
for (const [match, flags] of [...inlineMatches, ...startMatches]) {
|
|
9
|
+
const inlineMatches = regex.matchAll(/\?(-)?([a-z]):/g);
|
|
10
|
+
const startMatches = regex.matchAll(/\(\?(-)?([a-z]+)\)/g);
|
|
11
|
+
for (const [match, isNegative, flags] of [...inlineMatches, ...startMatches]) {
|
|
12
12
|
replace(match, '');
|
|
13
|
-
|
|
13
|
+
const func = (flag) => isNegative ? finalFlags.delete(flag) : finalFlags.add(flag);
|
|
14
|
+
[...flags].forEach(func);
|
|
14
15
|
}
|
|
15
16
|
// Remove PCRE-only syntax
|
|
16
17
|
replace(/([*+]){2}/g, '$1');
|
|
@@ -15,7 +15,8 @@ async function loadWebFile(file) {
|
|
|
15
15
|
return cachedContent;
|
|
16
16
|
// Otherwise cache the request
|
|
17
17
|
const dataUrl = (file) => `https://raw.githubusercontent.com/github/linguist/HEAD/lib/linguist/${file}`;
|
|
18
|
-
|
|
18
|
+
// Load file content, falling back to the local file if the request fails
|
|
19
|
+
const fileContent = await (0, cross_fetch_1.default)(dataUrl(file)).then(data => data.text()).catch(async () => await loadLocalFile(file));
|
|
19
20
|
cache.set(file, fileContent);
|
|
20
21
|
return fileContent;
|
|
21
22
|
}
|
package/dist/schema.d.ts
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export type LanguageResult = string | null;
|
|
2
|
-
export type Language = string;
|
|
3
|
-
export type Category = 'data' | 'markup' | 'programming' | 'prose';
|
|
4
|
-
export type FilePath = string;
|
|
5
|
-
export type Bytes = Integer;
|
|
6
|
-
export type Integer = number;
|
|
1
|
+
export declare type LanguageResult = string | null;
|
|
2
|
+
export declare type Language = string;
|
|
3
|
+
export declare type Category = 'data' | 'markup' | 'programming' | 'prose';
|
|
4
|
+
export declare type FilePath = string;
|
|
5
|
+
export declare type Bytes = Integer;
|
|
6
|
+
export declare type Integer = number;
|
|
7
7
|
export interface Options {
|
|
8
8
|
fileContent?: string | string[];
|
|
9
9
|
ignoredFiles?: string[];
|
package/ext/documentation.yml
CHANGED
package/ext/generated.rb
CHANGED
|
@@ -26,6 +26,7 @@ module Linguist
|
|
|
26
26
|
generated_net_specflow_feature_file? ||
|
|
27
27
|
composer_lock? ||
|
|
28
28
|
cargo_lock? ||
|
|
29
|
+
flake_lock? ||
|
|
29
30
|
node_modules? ||
|
|
30
31
|
go_vendor? ||
|
|
31
32
|
go_lock? ||
|
|
@@ -235,6 +236,9 @@ module Linguist
|
|
|
235
236
|
def cargo_lock?
|
|
236
237
|
!!name.match(/Cargo\.lock/)
|
|
237
238
|
end
|
|
239
|
+
def flake_lock?
|
|
240
|
+
!!name.match(/(^|\/)flake\.lock$/)
|
|
241
|
+
end
|
|
238
242
|
def vcr_cassette?
|
|
239
243
|
return false unless extname == '.yml'
|
|
240
244
|
return false unless lines.count > 2
|
|
@@ -392,4 +396,4 @@ module Linguist
|
|
|
392
396
|
end.select { |x| x.length == 2 }.to_h
|
|
393
397
|
end
|
|
394
398
|
end
|
|
395
|
-
end
|
|
399
|
+
end
|