Skip to content

Commit cbfc11a

Browse files
authored
Merge pull request #188 from Aghassi/fix/enoent-throwing
2 parents 310cb27 + 7684df0 commit cbfc11a

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

lib/LinkResolver.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
const fs = require("fs");
88
const path = require("path");
99

10-
const EXPECTED_ERRORS = new Set(
11-
process.platform === "win32" ? ["EINVAL", "ENOENT", "UNKNOWN"] : ["EINVAL"]
12-
);
10+
// macOS, Linux, and Windows all rely on these errors
11+
const EXPECTED_ERRORS = new Set(["EINVAL", "ENOENT"]);
12+
13+
// On Windows there is also this error in some cases
14+
if (process.platform === "win32") EXPECTED_ERRORS.add("UNKNOWN");
1315

1416
class LinkResolver {
1517
constructor() {

test/LinkResolver.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*globals describe it beforeEach afterEach */
2+
"use strict";
3+
4+
const should = require("should");
5+
const LinkResolver = require("../lib/LinkResolver");
6+
7+
describe("LinkResolver", () => {
8+
it("should not throw when a path resolves with ENOENT", () => {
9+
const resolver = new LinkResolver();
10+
const result = resolver.resolve("/path/to/nonexistent/file/or/folder");
11+
should.exist(result);
12+
});
13+
});

0 commit comments

Comments
 (0)