linguist-js 2.6.0 → 2.7.0-pre
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/cli.d.ts +1 -1
- package/dist/cli.js +141 -107
- package/dist/helpers/convert-pcre.d.ts +2 -0
- package/dist/helpers/convert-pcre.js +38 -38
- package/dist/helpers/load-data.d.ts +4 -0
- package/dist/helpers/load-data.js +38 -31
- package/dist/helpers/parse-gitattributes.d.ts +16 -0
- package/dist/helpers/parse-gitattributes.js +37 -0
- package/dist/helpers/read-file.d.ts +5 -0
- package/dist/helpers/read-file.js +23 -23
- package/dist/helpers/walk-tree.d.ts +20 -0
- package/dist/helpers/walk-tree.js +71 -64
- package/dist/index.d.ts +4 -4
- package/dist/index.js +429 -389
- package/dist/schema.d.ts +37 -37
- package/dist/schema.js +2 -2
- package/dist/types.d.ts +52 -48
- package/dist/types.js +2 -2
- package/ext/generated.rb +24 -399
- package/package.json +5 -6
- package/readme.md +40 -26
|
@@ -1,64 +1,71 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
let allFiles;
|
|
9
|
-
let allFolders;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
folders
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
let allFiles;
|
|
9
|
+
let allFolders;
|
|
10
|
+
;
|
|
11
|
+
;
|
|
12
|
+
/** Generate list of files in a directory. */
|
|
13
|
+
function walk(data) {
|
|
14
|
+
const { init, commonRoot, folderRoots, folders, ignored } = data;
|
|
15
|
+
// Initialise files and folders lists
|
|
16
|
+
if (init) {
|
|
17
|
+
allFiles = new Set();
|
|
18
|
+
allFolders = new Set();
|
|
19
|
+
}
|
|
20
|
+
// Walk tree of a folder
|
|
21
|
+
if (folders.length === 1) {
|
|
22
|
+
const folder = folders[0];
|
|
23
|
+
const localRoot = folderRoots[0].replace(commonRoot, '').replace(/^\//, '');
|
|
24
|
+
// Get list of files and folders inside this folder
|
|
25
|
+
const files = fs_1.default.readdirSync(folder).map(file => {
|
|
26
|
+
// Create path relative to root
|
|
27
|
+
const base = path_1.default.resolve(folder, file).replace(/\\/g, '/').replace(commonRoot, '.');
|
|
28
|
+
// Add trailing slash to mark directories
|
|
29
|
+
const isDir = fs_1.default.lstatSync(path_1.default.resolve(commonRoot, base)).isDirectory();
|
|
30
|
+
return isDir ? `${base}/` : base;
|
|
31
|
+
});
|
|
32
|
+
// Loop through files and folders
|
|
33
|
+
for (const file of files) {
|
|
34
|
+
// Create absolute path for disc operations
|
|
35
|
+
const path = path_1.default.resolve(commonRoot, file).replace(/\\/g, '/');
|
|
36
|
+
const localPath = localRoot ? file.replace(`./${localRoot}/`, '') : file.replace('./', '');
|
|
37
|
+
// Skip if nonexistant
|
|
38
|
+
const nonExistant = !fs_1.default.existsSync(path);
|
|
39
|
+
if (nonExistant)
|
|
40
|
+
continue;
|
|
41
|
+
// Skip if marked as ignored
|
|
42
|
+
const isIgnored = ignored.test(localPath).ignored;
|
|
43
|
+
if (isIgnored)
|
|
44
|
+
continue;
|
|
45
|
+
// Add absolute folder path to list
|
|
46
|
+
allFolders.add(path_1.default.resolve(folder).replace(/\\/g, '/'));
|
|
47
|
+
// Check if this is a folder or file
|
|
48
|
+
if (file.endsWith('/')) {
|
|
49
|
+
// Recurse into subfolders
|
|
50
|
+
allFolders.add(path);
|
|
51
|
+
walk({ init: false, commonRoot, folderRoots, folders: [path], ignored });
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// Add file path to list
|
|
55
|
+
allFiles.add(path);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Recurse into all folders
|
|
60
|
+
else {
|
|
61
|
+
for (const i in folders) {
|
|
62
|
+
walk({ init: false, commonRoot, folderRoots: [folderRoots[i]], folders: [folders[i]], ignored });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Return absolute files and folders lists
|
|
66
|
+
return {
|
|
67
|
+
files: [...allFiles].map(file => file.replace(/^\./, commonRoot)),
|
|
68
|
+
folders: [...allFolders],
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
exports.default = walk;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as T from './types';
|
|
2
|
-
declare function analyse(path?: string, opts?: T.Options): Promise<T.Results>;
|
|
3
|
-
declare function analyse(paths?: string[], opts?: T.Options): Promise<T.Results>;
|
|
4
|
-
export = analyse;
|
|
1
|
+
import * as T from './types';
|
|
2
|
+
declare function analyse(path?: string, opts?: T.Options): Promise<T.Results>;
|
|
3
|
+
declare function analyse(paths?: string[], opts?: T.Options): Promise<T.Results>;
|
|
4
|
+
export = analyse;
|