-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ensured path resolution on legacy Node supports local modules
note that path resolution for third-party packages currently fails on Node v8 if CWD is not the same as `referenceDir`: nodejs/node#18686
- Loading branch information
Showing
7 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
void 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
void 0; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* global describe, before, after, it */ | ||
"use strict"; | ||
|
||
let AssetManager = require("../lib/manager"); | ||
let path = require("path"); | ||
let assert = require("assert"); | ||
|
||
let assertSame = assert.strictEqual; | ||
|
||
describe("asset manager", _ => { | ||
let cwd; | ||
|
||
before(() => { | ||
cwd = process.cwd(); | ||
}); | ||
|
||
after(() => { | ||
process.chdir(cwd); | ||
}); | ||
|
||
it("resolves file paths for local modules and third-party packages", () => { | ||
let root = path.resolve(__dirname, "fixtures"); | ||
process.chdir(root); | ||
|
||
let { resolvePath } = new AssetManager(root); | ||
|
||
let filepath = resolvePath("dummy/src.js"); | ||
assertSame(path.relative(root, filepath), "dummy/src.js"); | ||
|
||
filepath = resolvePath("dummy/pkg.js"); | ||
assertSame(path.relative(root, filepath), "node_modules/dummy/pkg.js"); | ||
|
||
// local modules take precedence over third-party packages | ||
["dummy", "dummy/index", "dummy/index.js"].forEach(module => { | ||
let filepath = resolvePath(module); | ||
assertSame(path.relative(root, filepath), "dummy/index.js"); | ||
}); | ||
}); | ||
}); |