5
5
const common = require ( '../common' ) ;
6
6
const assert = require ( 'assert' ) ;
7
7
const fs = require ( 'fs' ) ;
8
- const path = require ( 'path' ) ;
9
8
const Module = require ( 'module' ) ;
10
9
const tmpdir = require ( '../common/tmpdir' ) ;
11
- const file = path . join ( tmpdir . path , 'test-extensions.foo.bar' ) ;
12
- const dotfile = path . join ( tmpdir . path , '.bar' ) ;
13
- const dotfileWithExtension = path . join ( tmpdir . path , '.foo.bar' ) ;
10
+ const file = tmpdir . resolve ( 'test-extensions.foo.bar' ) ;
11
+ const dotfile = tmpdir . resolve ( '.bar' ) ;
12
+ const dotfileWithExtension = tmpdir . resolve ( '.foo.bar' ) ;
14
13
15
14
tmpdir . refresh ( ) ;
16
15
fs . writeFileSync ( file , 'console.log(__filename);' , 'utf8' ) ;
@@ -20,7 +19,7 @@ fs.writeFileSync(dotfileWithExtension, 'console.log(__filename);', 'utf8');
20
19
{
21
20
require . extensions [ '.bar' ] = common . mustNotCall ( ) ;
22
21
require . extensions [ '.foo.bar' ] = common . mustCall ( ) ;
23
- const modulePath = path . join ( tmpdir . path , 'test-extensions' ) ;
22
+ const modulePath = tmpdir . resolve ( 'test-extensions' ) ;
24
23
require ( modulePath ) ;
25
24
require ( file ) ;
26
25
delete require . cache [ file ] ;
@@ -31,7 +30,7 @@ fs.writeFileSync(dotfileWithExtension, 'console.log(__filename);', 'utf8');
31
30
32
31
{
33
32
require . extensions [ '.foo.bar' ] = common . mustCall ( ) ;
34
- const modulePath = path . join ( tmpdir . path , 'test-extensions' ) ;
33
+ const modulePath = tmpdir . resolve ( 'test-extensions' ) ;
35
34
require ( modulePath ) ;
36
35
assert . throws (
37
36
( ) => require ( `${ modulePath } .foo` ) ,
@@ -44,7 +43,7 @@ fs.writeFileSync(dotfileWithExtension, 'console.log(__filename);', 'utf8');
44
43
}
45
44
46
45
{
47
- const modulePath = path . join ( tmpdir . path , 'test-extensions' ) ;
46
+ const modulePath = tmpdir . resolve ( 'test-extensions' ) ;
48
47
assert . throws (
49
48
( ) => require ( modulePath ) ,
50
49
( err ) => err . message . startsWith ( `Cannot find module '${ modulePath } '` )
@@ -56,7 +55,7 @@ fs.writeFileSync(dotfileWithExtension, 'console.log(__filename);', 'utf8');
56
55
{
57
56
require . extensions [ '.bar' ] = common . mustNotCall ( ) ;
58
57
require . extensions [ '.foo.bar' ] = common . mustCall ( ) ;
59
- const modulePath = path . join ( tmpdir . path , 'test-extensions.foo' ) ;
58
+ const modulePath = tmpdir . resolve ( 'test-extensions.foo' ) ;
60
59
require ( modulePath ) ;
61
60
delete require . cache [ file ] ;
62
61
delete require . extensions [ '.bar' ] ;
@@ -66,7 +65,7 @@ fs.writeFileSync(dotfileWithExtension, 'console.log(__filename);', 'utf8');
66
65
67
66
{
68
67
require . extensions [ '.foo.bar' ] = common . mustNotCall ( ) ;
69
- const modulePath = path . join ( tmpdir . path , 'test-extensions.foo' ) ;
68
+ const modulePath = tmpdir . resolve ( 'test-extensions.foo' ) ;
70
69
assert . throws (
71
70
( ) => require ( modulePath ) ,
72
71
( err ) => err . message . startsWith ( `Cannot find module '${ modulePath } '` )
0 commit comments