-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvalidate-symlinks.ts
More file actions
52 lines (43 loc) · 1.3 KB
/
validate-symlinks.ts
File metadata and controls
52 lines (43 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.
/**
* Symlink checker — detects broken and destroyed symlinks.
*
* @module
*/
import * as standards from "@eserstack/standards";
import { createFileTool, type FileTool } from "./file-tool.ts";
export const tool: FileTool = createFileTool({
name: "validate-symlinks",
description: "Detect broken symlinks",
canFix: false,
stacks: [],
defaults: {},
async checkAll(files) {
const issues = [];
for (const file of files) {
if (!file.isSymlink) {
continue;
}
// Only flag BROKEN symlinks (target doesn't exist).
// Valid symlinks like AGENTS.md → CLAUDE.md pass silently.
try {
await standards.crossRuntime.runtime.fs.stat(file.path);
} catch {
issues.push({
path: file.path,
message: "broken symlink — target not found",
});
}
}
return issues;
},
});
export const run: FileTool["run"] = tool.run;
export const validator: FileTool["validator"] = tool.validator;
export const main: FileTool["main"] = tool.main;
if (import.meta.main) {
const { runCliMain } = await import("./cli-support.ts");
runCliMain(
await main(standards.crossRuntime.runtime.process.args as string[]),
);
}