forked from istanbuljs/esm-loader-hook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Do not attempt to recursively load configuration (istanbuljs#2)
If this transform hook is set for the main nyc process the configuration load causes this hook to run. This resulted in process failure. Return original source when `@istanbuljs/load-nyc-config` is loading a configuration file.
- Loading branch information
1 parent
9599c36
commit bc4d4e1
Showing
6 changed files
with
60 additions
and
8 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,5 @@ | ||
import loader from '@istanbuljs/load-nyc-config'; | ||
|
||
export default { | ||
include: loader.isLoading() ? ['hooked.js'] : [] | ||
}; |
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,6 @@ | ||
{ | ||
"type": "module", | ||
"peerDependencies": { | ||
"@istanbuljs/load-nyc-config": "*" | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {fileURLToPath} from 'url'; | ||
|
||
import t from 'libtap'; | ||
import loader from '@istanbuljs/load-nyc-config'; | ||
|
||
t.test('load config', async t => { | ||
const config = await loader.loadNycConfig(); | ||
|
||
t.same(config.include, ['hooked.js']); | ||
|
||
await import('../fixtures/hooked.js'); | ||
|
||
const transformFile = fileURLToPath(new URL('../fixtures/hooked.js', import.meta.url).href); | ||
|
||
t.equal(Object.keys(global.__coverage__).length, 1); | ||
const transformCoverage = global.__coverage__[transformFile]; | ||
t.equal(transformCoverage.path, transformFile); | ||
}); |