File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed
fixtures/require-empty-main Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ module . exports = 42 ;
Original file line number Diff line number Diff line change 1+ {"main" :" " }
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ require ( '../common' ) ;
3+
4+ // A package.json with an empty "main" property should use index.js if present.
5+ // require.resolve() should resolve to index.js for the same reason.
6+ //
7+ // In fact, any "main" property that doesn't resolve to a file should result
8+ // in index.js being used, but that's already checked for by other tests.
9+ // This test only concerns itself with the empty string.
10+
11+ const assert = require ( 'assert' ) ;
12+ const path = require ( 'path' ) ;
13+ const fixtures = require ( '../common/fixtures' ) ;
14+
15+ const where = fixtures . path ( 'require-empty-main' ) ;
16+ const expected = path . join ( where , 'index.js' ) ;
17+
18+ test ( ) ;
19+ setImmediate ( test ) ;
20+
21+ function test ( ) {
22+ assert . strictEqual ( require . resolve ( where ) , expected ) ;
23+ assert . strictEqual ( require ( where ) , 42 ) ;
24+ assert . strictEqual ( require . resolve ( where ) , expected ) ;
25+ }
You can’t perform that action at this time.
0 commit comments