| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3d64c9e commit 862cd2b
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + module.exports = 42; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + {"main":""} | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,25 @@ | |||
| 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 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments