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.
@@ -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
- [...flags].forEach(flag => finalFlags.add(flag));
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
- const fileContent = await (0, cross_fetch_1.default)(dataUrl(file)).then(data => data.text());
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
@@ -33,5 +33,5 @@ export interface HeuristicsSchema {
33
33
  }>;
34
34
  named_patterns: Record<string, string | string[]>;
35
35
  }
36
- export type VendorSchema = string[];
36
+ export declare type VendorSchema = string[];
37
37
  export {};
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[];
@@ -18,4 +18,4 @@
18
18
  - (^|/)[Ll]icen[cs]e(\.|$)
19
19
  - (^|/)README(\.|$)
20
20
  - (^|/)[Rr]eadme(\.|$)
21
- - ^[Ss]amples?/
21
+ - ^[Ss]amples?/
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