Skip to content

Commit

Permalink
chore: skip loading task when compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
JhChoy committed Dec 28, 2023
1 parent 8ffa216 commit db60194
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
14 changes: 13 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import 'hardhat-contract-sizer'
import 'hardhat-abi-exporter'
import '@nomicfoundation/hardhat-verify'

import './task/index'
import { HardhatConfig } from 'hardhat/types'
import * as networkInfos from 'viem/chains'
import path from 'path'

dotenv.config()

Expand All @@ -22,6 +22,18 @@ for (const [networkName, networkInfo] of Object.entries(networkInfos)) {
chainIdMap[networkInfo.id] = networkName
}

const SKIP_LOAD = process.env.SKIP_LOAD === 'true'

// Prevent to load scripts before compilation and typechain
if (!SKIP_LOAD) {
const tasksPath = path.join(__dirname, 'task')
fs.readdirSync(tasksPath)
.filter((pth) => pth.includes('.ts'))
.forEach((task) => {
require(`${tasksPath}/${task}`)
})
}

let privateKey: string
let ok: string

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"scripts": {
"fork": "npx hardhat node",
"compile": "TS_NODE_TRANSPILE_ONLY=1 npx hardhat compile",
"compile": "TS_NODE_TRANSPILE_ONLY=1 SKIP_LOAD=true npx hardhat compile",
"coverage:forge": "forge coverage --report lcov",
"coverage:local": "rm -rf coverage && forge coverage --report lcov && genhtml lcov.info -o coverage --branch-coverage && open coverage/index.html",
"test:hardhat": "npx hardhat test",
Expand Down
3 changes: 0 additions & 3 deletions task/index.ts

This file was deleted.

0 comments on commit db60194

Please sign in to comment.