Skip to content

solidstate-network/hardhat-git

Repository files navigation

Hardhat Git

Isolated HRE execution based on Git refs.

Installation

npm install --save-dev @solidstate/hardhat-git
# or
yarn add --dev @solidstate/hardhat-git

Usage

This 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 reference.
  • 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 reference:

import { createHardhatRuntimeEnvironmentAtGitRef } from '@solidstate/hardhat-git';

const gitHre = await createHardhatRuntimeEnvironmentAtGitRef(hre, 'HEAD~1');

Optionally declare the plugin as a dependency to expose the helper tasks:

const plugin: HardhatPlugin = {
  dependencies: [
    async () => {
      const { default: HardhatGit } = await import('@solidstate/hardhat-git');
      return HardhatGit;
    },
  ],
};

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'

Development

Install dependencies via Yarn:

yarn install

Setup Husky to format code on commit:

yarn prepare

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages