Skip to content

Commit

Permalink
chore: add try..catch for stat in scanDirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberalien committed Dec 16, 2024
1 parent 68dc28c commit a31225c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion @iconify/tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "module",
"description": "Collection of functions for cleaning up and parsing SVG for Iconify project",
"author": "Vjacheslav Trushkin",
"version": "4.1.0",
"version": "4.1.1",
"license": "MIT",
"bugs": "https://github.com/iconify/tools/issues",
"homepage": "https://github.com/iconify/tools",
Expand Down
5 changes: 3 additions & 2 deletions @iconify/tools/src/icon-set/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,8 @@ export class IconSet {
const attributes = Object.keys(result.attributes)
.map(
(key) =>
` ${key}="${result.attributes[key as keyof typeof result.attributes]
` ${key}="${
result.attributes[key as keyof typeof result.attributes]
}"`
)
.join('');
Expand Down Expand Up @@ -741,7 +742,7 @@ export class IconSet {
*/
rename(oldName: string, newName: string): boolean {
if (oldName === newName) {
return false
return false;
}

const entries = this.entries;
Expand Down
16 changes: 14 additions & 2 deletions @iconify/tools/src/misc/scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ export async function scanDirectory(
continue;
}

const stat = await fs.stat(path + subdir + filename);
let stat: Stats;
try {
stat = await fs.stat(path + subdir + filename);
} catch (err) {
// Failed
continue;
}
if (stat.isDirectory()) {
if (subdirs) {
await scan(subdir + filename + '/');
Expand Down Expand Up @@ -167,7 +173,13 @@ export function scanDirectorySync(
continue;
}

const stat = statSync(path + subdir + filename);
let stat: Stats;
try {
stat = statSync(path + subdir + filename);
} catch (err) {
// Failed
continue;
}
if (stat.isDirectory()) {
if (subdirs) {
scan(subdir + filename + '/');
Expand Down

0 comments on commit a31225c

Please sign in to comment.