Skip to content

Commit

Permalink
fix: adds ENOENT for non windows errors
Browse files Browse the repository at this point in the history
Solves for use case where Webpack is running under Bazel
with iBazel. Heavily relies on symlinks set up in a certain way See bazelbuild/rules_nodejs#2431
  • Loading branch information
Aghassi authored and sokra committed Feb 7, 2021
1 parent 310cb27 commit 7684df0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/LinkResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
const fs = require("fs");
const path = require("path");

const EXPECTED_ERRORS = new Set(
process.platform === "win32" ? ["EINVAL", "ENOENT", "UNKNOWN"] : ["EINVAL"]
);
// macOS, Linux, and Windows all rely on these errors
const EXPECTED_ERRORS = new Set(["EINVAL", "ENOENT"]);

// On Windows there is also this error in some cases
if (process.platform === "win32") EXPECTED_ERRORS.add("UNKNOWN");

class LinkResolver {
constructor() {
Expand Down
13 changes: 13 additions & 0 deletions test/LinkResolver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*globals describe it beforeEach afterEach */
"use strict";

const should = require("should");
const LinkResolver = require("../lib/LinkResolver");

describe("LinkResolver", () => {
it("should not throw when a path resolves with ENOENT", () => {
const resolver = new LinkResolver();
const result = resolver.resolve("/path/to/nonexistent/file/or/folder");
should.exist(result);
});
});

0 comments on commit 7684df0

Please sign in to comment.