Add variable on global HH env identifying solidity-coverage task (#682)

pull/689/head
cgewecke 3 years ago committed by GitHub
parent 5b7eb34e66
commit 81c6b50f43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      README.md
  2. 3
      plugins/hardhat.plugin.js

@ -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:

@ -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);

Loading…
Cancel
Save