Skip to content

Commit 725020c

Browse files
authored
fix: XML validation crash on symlinks and special files
1 parent bf353c6 commit 725020c

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

index.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,23 @@ import * as paths from "path";
55

66
async function walk(dir) {
77
let files = fs.readdirSync(dir, { withFileTypes: true });
8+
89
files = await Promise.all(
910
files.map(async (dirEnt) => {
1011
const filePath = paths.join(dir, dirEnt.name); // dirEnt.path does not yet exist in nodejs 16.16.0
12+
1113
if (dirEnt.isDirectory()) {
1214
return walk(filePath);
13-
} else {
14-
if (dirEnt.isFile()) {
15-
return filePath;
16-
}
1715
}
16+
17+
if (dirEnt.isFile()) {
18+
return filePath;
19+
}
20+
21+
return [];
1822
})
1923
);
24+
2025
return files.reduce((all, folderContents) => all.concat(folderContents), []);
2126
}
2227

@@ -48,7 +53,7 @@ export async function validate(path, extensionsStr) {
4853
allowBooleanAttributes: false,
4954
});
5055
if (result !== true) {
51-
outErrorStr = `file '${file}', colum ${result.err.col}, line ${result.err.line}: ${result.err.code} - ${result.err.msg}`;
56+
outErrorStr = `file '${file}', column ${result.err.col}, line ${result.err.line}: ${result.err.code} - ${result.err.msg}`;
5257
return false;
5358
}
5459
++fileCount;

0 commit comments

Comments
 (0)