@mintlify/prebuild 1.0.1260 → 1.0.1261
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/fs/index.d.ts +1 -1
- package/dist/fs/index.js +42 -5
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/fs/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const getFileListSync: (dirName: string, og?: string) => string[];
|
|
1
|
+
export declare const getFileListSync: (dirName: string, og?: string, ancestors?: Set<string>, root?: string) => string[];
|
|
2
2
|
export declare const getFileListWithDirectories: (dirName: string, og?: string) => string[];
|
|
3
3
|
export declare function getFileList(dirName: string, og?: string, mintIgnore?: string[]): AsyncIterable<string>;
|
package/dist/fs/index.js
CHANGED
|
@@ -1,19 +1,56 @@
|
|
|
1
1
|
import { isMintIgnored, toPosixPath } from '@mintlify/common';
|
|
2
|
-
import { readdirSync } from 'fs';
|
|
2
|
+
import { readdirSync, realpathSync, statSync } from 'fs';
|
|
3
3
|
import { readdir } from 'fs/promises';
|
|
4
4
|
import path from 'path';
|
|
5
|
-
export const getFileListSync = (dirName, og = dirName) => {
|
|
5
|
+
export const getFileListSync = (dirName, og = dirName, ancestors = new Set(), root) => {
|
|
6
6
|
const files = [];
|
|
7
|
-
|
|
7
|
+
let realDir;
|
|
8
|
+
try {
|
|
9
|
+
realDir = realpathSync(dirName);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return files;
|
|
13
|
+
}
|
|
14
|
+
const realRoot = root ?? realDir;
|
|
15
|
+
if (realDir !== realRoot && !realDir.startsWith(realRoot + path.sep)) {
|
|
16
|
+
return files;
|
|
17
|
+
}
|
|
18
|
+
if (ancestors.has(realDir)) {
|
|
19
|
+
return files;
|
|
20
|
+
}
|
|
21
|
+
ancestors.add(realDir);
|
|
22
|
+
let items;
|
|
23
|
+
try {
|
|
24
|
+
items = readdirSync(dirName, { withFileTypes: true });
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
ancestors.delete(realDir);
|
|
28
|
+
return files;
|
|
29
|
+
}
|
|
8
30
|
for (const item of items) {
|
|
31
|
+
if (item.name === 'node_modules' || item.name === '.git') {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
9
34
|
const fullPath = path.join(dirName, item.name);
|
|
10
|
-
|
|
11
|
-
|
|
35
|
+
let isDirectory = item.isDirectory();
|
|
36
|
+
if (item.isSymbolicLink()) {
|
|
37
|
+
try {
|
|
38
|
+
isDirectory = statSync(fullPath).isDirectory();
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (isDirectory) {
|
|
45
|
+
for (const file of getFileListSync(fullPath, og, ancestors, realRoot)) {
|
|
46
|
+
files.push(file);
|
|
47
|
+
}
|
|
12
48
|
}
|
|
13
49
|
else {
|
|
14
50
|
files.push(toPosixPath(path.relative(og, fullPath)));
|
|
15
51
|
}
|
|
16
52
|
}
|
|
53
|
+
ancestors.delete(realDir);
|
|
17
54
|
return files;
|
|
18
55
|
};
|
|
19
56
|
// TODO consolidate this function
|