-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This was added in v8.9.0: https://nodejs.org/api/modules.html#modules_require_resolve_paths_request
- Loading branch information
Showing
3 changed files
with
65 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('%j', require.resolve.paths(process.argv[2])); |
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,51 @@ | ||
'use strict'; | ||
|
||
const tap = require('tap'); | ||
const child_process = require('child_process'); | ||
const path = require('path'); | ||
|
||
tap.beforeEach(cb => { | ||
delete process.env.DISABLE_V8_COMPILE_CACHE; | ||
cb(); | ||
}); | ||
|
||
tap.test('require.resolve.paths module', t => { | ||
const ps = child_process.spawnSync( | ||
process.execPath, | ||
[ | ||
'--require', | ||
'..', | ||
require.resolve('./fixtures/require-resolve-paths'), | ||
'tap', | ||
], | ||
{cwd: __dirname} | ||
); | ||
|
||
const expected = [path.resolve(__dirname, 'fixtures', 'node_modules')] | ||
.concat(require.resolve.paths('tap')); | ||
|
||
t.same(JSON.parse(ps.stdout), expected); | ||
t.equal(ps.stderr.toString(), ''); | ||
t.equal(ps.status, 0); | ||
|
||
t.end(); | ||
}); | ||
|
||
tap.test('require.resolve.paths relative', t => { | ||
const ps = child_process.spawnSync( | ||
process.execPath, | ||
[ | ||
'--require', | ||
'..', | ||
require.resolve('./fixtures/require-resolve-paths'), | ||
'./foo', | ||
], | ||
{cwd: __dirname} | ||
); | ||
|
||
t.same(JSON.parse(ps.stdout), [path.resolve(__dirname, 'fixtures')]); | ||
t.equal(ps.stderr.toString(), ''); | ||
t.equal(ps.status, 0); | ||
|
||
t.end(); | ||
}); |
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