From db60194660406a8b6390297757c2cf72b4e554b1 Mon Sep 17 00:00:00 2001 From: JChoy Date: Fri, 29 Dec 2023 04:30:01 +0900 Subject: [PATCH] chore: skip loading task when compiling --- hardhat.config.ts | 14 +++++++++++++- package.json | 2 +- task/index.ts | 3 --- 3 files changed, 14 insertions(+), 5 deletions(-) delete mode 100644 task/index.ts diff --git a/hardhat.config.ts b/hardhat.config.ts index 7e05d02..c66cff6 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -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() @@ -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 diff --git a/package.json b/package.json index e43e94e..2a0a8c1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/task/index.ts b/task/index.ts deleted file mode 100644 index 6bb2722..0000000 --- a/task/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import './coupon.ts' -import './utils.ts' -import './substitute.ts'