Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ const CoverageAPI = require('solidity-coverage/api');

[Documentation available here][28].

## Detecting solidity-coverage from another task

If you're writing another plugin or task, it can be helpful to detect whether coverage is running or not.
The coverage plugin sets a boolean variable on the globally injected hardhat environment object for this purpose.

```
hre.__SOLIDITY_COVERAGE_RUNNING === true
```

## FAQ

Common problems & questions:
Expand Down
3 changes: 3 additions & 0 deletions plugins/hardhat.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ task("coverage", "Generates a code coverage report for tests")
instrumentedSources = {};
measureCoverage = true;

// Set a variable on the environment so other tasks can detect if this task is executing
env.__SOLIDITY_COVERAGE_RUNNING = true;

try {
config = nomiclabsUtils.normalizeConfig(env.config, args);
ui = new PluginUI(config.logger.log);
Expand Down