Skip to content

Commit fcf1d0a

Browse files
committed
fix: resolve conversations
1 parent 52efb48 commit fcf1d0a

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed
File renamed without changes.

checkFilenames.mjs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import fs from 'fs';
22
import path from 'path';
3-
import { fileURLToPath } from 'url';
43

5-
const __filename = fileURLToPath(import.meta.url);
6-
const __dirname = path.dirname(__filename);
4+
const __dirname = import.meta.dirname;
75

86
function getAllFiles(dirPath) {
9-
let nonKebabElements = [];
7+
let incorrectFormatFiles = [];
108
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
119

12-
const kebabCaseRegex = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
10+
const filenameFormat = /^[a-z0-9]+(?:[-.][a-z0-9]+)*$/;
1311

1412
for (const entry of entries) {
1513
// Skip certain files/folders
@@ -27,18 +25,18 @@ function getAllFiles(dirPath) {
2725
? path.parse(entry.name).name
2826
: entry.name;
2927

30-
if (!kebabCaseRegex.test(nameToTest)) {
31-
nonKebabElements.push(path.join(dirPath, entry.name));
28+
if (!filenameFormat.test(nameToTest)) {
29+
incorrectFormatFiles.push(path.join(dirPath, entry.name));
3230
}
3331

3432
// Recursively check subdirectories
3533
if (entry.isDirectory()) {
3634
const subDirResults = getAllFiles(path.join(dirPath, entry.name));
37-
nonKebabElements = nonKebabElements.concat(subDirResults);
35+
incorrectFormatFiles = incorrectFormatFiles.concat(subDirResults);
3836
}
3937
}
4038

41-
return nonKebabElements;
39+
return incorrectFormatFiles;
4240
}
4341

4442
const folders = ['docs', 'blog'];

0 commit comments

Comments
 (0)