forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
module: accept Windows relative path
Before this change, require('.\\test.js') failed while require('./test.js') succeeded. This changes _resolveLookupPaths so that both ways are accepted on Windows. Fixes: nodejs#21918
- Loading branch information
1 parent
59e5a39
commit cf0e7c2
Showing
2 changed files
with
25 additions
and
14 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,23 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const _module = require('module'); // avoid collision with global.module | ||
const lookupResults = _module._resolveLookupPaths('./lodash'); | ||
let paths = lookupResults[1]; | ||
|
||
// Current directory gets highest priority for local modules | ||
assert.strictEqual(paths[0], '.'); | ||
function runTest(moduleName) { | ||
const lookupResults = _module._resolveLookupPaths(moduleName); | ||
let paths = lookupResults[1]; | ||
|
||
paths = _module._resolveLookupPaths('./lodash', null, true); | ||
// Current directory gets highest priority for local modules | ||
assert.strictEqual(paths[0], '.'); | ||
|
||
// Current directory gets highest priority for local modules | ||
assert.strictEqual(paths && paths[0], '.'); | ||
paths = _module._resolveLookupPaths(moduleName, null, true); | ||
|
||
// Current directory gets highest priority for local modules | ||
assert.strictEqual(paths && paths[0], '.'); | ||
} | ||
|
||
runTest('./lodash'); | ||
if (common.isWindows) { | ||
runTest('.\\lodash'); | ||
} |