Skip to content

Commit a29fd85

Browse files
committed
Solely use the local filesystem, not git
1 parent b142486 commit a29fd85

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

dist/validateLinks.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@ import { readFile } from "node:fs/promises";
33
import { parse } from "./parse.js";
44
import path, { dirname, normalize } from "node:path/posix";
55
import { isAbsolute } from "node:path";
6-
const findAllFilesInGit = async () => {
6+
const findAllFiles = async () => {
77
return await new Promise((resolve, reject) => {
8-
exec("git ls-files -z", (error, stdout, stderr) => {
8+
exec("find . -mindepth 1 -name node_modules -prune -o -name .git -prune -o -print0", (error, stdout, stderr) => {
99
if (error)
1010
reject(error);
1111
if (stderr)
12-
reject(new Error(`git ls-files outputted on stderr: ${stderr}`));
12+
reject(new Error(`'find' outputted on stderr: ${stderr}`));
1313
else
14-
resolve(stdout.split("\0").filter(Boolean));
14+
resolve(stdout
15+
.split("\0")
16+
.filter(Boolean)
17+
.map((s) => s.substring(2)));
1518
});
1619
});
1720
};
@@ -34,7 +37,7 @@ const showError = (filename, sourceLocation, code, message) => {
3437
const externalLinkPattern = /^\w+:/;
3538
const isExternalLink = (t) => externalLinkPattern.test(t);
3639
const main = async () => {
37-
const gitFiles = await findAllFilesInGit();
40+
const gitFiles = await findAllFiles();
3841
// For now, we assume that there are no case clashes
3942
const lowercaseGitFiles = gitFiles.map((s) => s.toLocaleLowerCase());
4043
const markdownFilenames = findMarkdownFiles(gitFiles);

validateLinks.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,22 @@ import type { SourceLocation } from "./sourceLocation.js";
88

99
type ParsedFile = ParseResult & { readonly filename: string };
1010

11-
const findAllFilesInGit = async (): Promise<string[]> => {
11+
const findAllFiles = async (): Promise<string[]> => {
1212
return await new Promise((resolve, reject) => {
13-
exec("git ls-files -z", (error, stdout, stderr) => {
14-
if (error) reject(error);
15-
if (stderr)
16-
reject(new Error(`git ls-files outputted on stderr: ${stderr}`));
17-
else resolve(stdout.split("\0").filter(Boolean));
18-
});
13+
exec(
14+
"find . -mindepth 1 -name node_modules -prune -o -name .git -prune -o -print0",
15+
(error, stdout, stderr) => {
16+
if (error) reject(error);
17+
if (stderr) reject(new Error(`'find' outputted on stderr: ${stderr}`));
18+
else
19+
resolve(
20+
stdout
21+
.split("\0")
22+
.filter(Boolean)
23+
.map((s) => s.substring(2)), // Remove leading "./"
24+
);
25+
},
26+
);
1927
});
2028
};
2129

@@ -51,7 +59,7 @@ const externalLinkPattern = /^\w+:/;
5159
const isExternalLink = (t: string) => externalLinkPattern.test(t);
5260

5361
const main = async () => {
54-
const gitFiles = await findAllFilesInGit();
62+
const gitFiles = await findAllFiles();
5563

5664
// For now, we assume that there are no case clashes
5765
const lowercaseGitFiles = gitFiles.map((s) => s.toLocaleLowerCase());

0 commit comments

Comments
 (0)