-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy pathcheck-filenames.mjs
More file actions
55 lines (43 loc) · 1.26 KB
/
check-filenames.mjs
File metadata and controls
55 lines (43 loc) · 1.26 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
53
54
55
#!/usr/bin/env node
/**
* Filename convention checker for documentation files.
*
* Ensures no underscores are used in folder or file names,
* as URLs should only use hyphens.
*
* Usage: node dev/check-filenames.mjs
*/
import path from 'path';
import { glob } from 'glob';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const DOCS_DIR = path.join(path.dirname(__dirname), 'docs');
async function main() {
console.log('🔍 Checking for underscores in docs filenames...\n');
const files = await glob('**/*', { cwd: DOCS_DIR });
const errors = [];
for (const file of files) {
const parts = file.split('/');
for (const part of parts) {
if (part.includes('_')) {
errors.push(file);
break;
}
}
}
if (errors.length === 0) {
console.log('✅ No underscores found in filenames!');
process.exit(0);
}
console.log(`❌ Found ${errors.length} path(s) with underscores:\n`);
for (const file of errors) {
console.log(` docs/${file}`);
}
console.log('\n Please use hyphens (-) instead of underscores (_) in file and folder names.\n');
process.exit(1);
}
main().catch(err => {
console.error('Error running filename checker:', err);
process.exit(1);
});