Skip to content

Commit 1a1cecc

Browse files
committed
Catch ENAMETOOLONG as return false in isFilePromise
1 parent b4c9695 commit 1a1cecc

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

dist/node/cjs/utils/base64.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,18 @@ const isFilePromise = (file) =>
1414
}
1515
fs_1.default.stat(file, (err, stats) => {
1616
if (err) {
17+
if (err.code == 'ENAMETOOLONG') {
18+
resolve(false);
19+
return;
20+
}
1721
reject(err);
22+
return;
1823
}
19-
resolve(stats === undefined ? false : stats.isFile());
24+
if (stats === undefined) {
25+
resolve(false);
26+
return;
27+
}
28+
resolve(stats.isFile());
2029
});
2130
});
2231
const isBuffer = (file) => file instanceof Buffer;

dist/node/esm/utils/base64.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,18 @@ const isFilePromise = (file) =>
66
}
77
fs.stat(file, (err, stats) => {
88
if (err) {
9+
if (err.code == 'ENAMETOOLONG') {
10+
resolve(false);
11+
return;
12+
}
913
reject(err);
14+
return;
1015
}
11-
resolve(stats === undefined ? false : stats.isFile());
16+
if (stats === undefined) {
17+
resolve(false);
18+
return;
19+
}
20+
resolve(stats.isFile());
1221
});
1322
});
1423
const isBuffer = (file) => file instanceof Buffer;

src/utils/base64.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,18 @@ const isFilePromise = (file: string | Buffer): Promise<boolean> =>
77
}
88
fs.stat(file, (err, stats) => {
99
if (err) {
10+
if (err.code == 'ENAMETOOLONG') {
11+
resolve(false);
12+
return;
13+
}
1014
reject(err);
15+
return;
1116
}
12-
resolve(stats === undefined ? false : stats.isFile());
17+
if (stats === undefined) {
18+
resolve(false);
19+
return;
20+
}
21+
resolve(stats.isFile());
1322
});
1423
});
1524

0 commit comments

Comments
 (0)