Isolated HRE execution based on Git revisions.
npm install --save-dev @solidstate/hardhat-git
# or
pnpm add -D @solidstate/hardhat-gitThis plugin is primarily intended to be a dependency for other plugins. It exposes a custom HRE factory which does the following:
- Create a temporary clone of the current repository.
- Check out the specified git revision.
- Install NPM dependencies.
The returned HRE instance can be used just like a standard HRE.
See the @solidstate/hardhat-contract-sizer and @solidstate/hardhat-storage-layout-diff packages for implementation examples.
Load the factory and checkout a git revision:
import { createHardhatRuntimeEnvironmentAtGitRev } from '@solidstate/hardhat-git';
const gitHre = await createHardhatRuntimeEnvironmentAtGitRev(hre, 'HEAD~1');Optionally declare the plugin as a dependency to expose the helper tasks:
const plugin: HardhatPlugin = {
dependencies: () => [import('@solidstate/hardhat-git')),
};Load plugin standalone in Hardhat config:
import hardhatGit from '@solidstate/hardhat-git';
const config: HardhatUserConfig = {
plugins: [
hardhatGit,
],
git: {
... // see table for configuration options
},
};Add configuration under the git key:
| option | description | default |
|---|---|---|
npmInstall |
Command used to install NPM dependencies in repository clones | inferred via package-manager-detector, falls back to'npm install' |
Install dependencies via pnpm:
pnpm installSetup Husky to format code on commit:
pnpm prepareThe test suite verifies package manager inference and explicit overrides for npm, yarn, and bun. In addition to pnpm, you must have npm, yarn, and bun installed and available on your $PATH for the tests to pass.