Skip to content

Commit

Permalink
Merge pull request #243 from chugsplash/sg/develop
Browse files Browse the repository at this point in the history
fix(pg): fix BaseServiceV2 arg parsing bug in hardhat tasks
  • Loading branch information
sam-goldman authored Nov 22, 2022
2 parents 23bf270 + 917d50d commit a5af6ab
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/old-ads-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chugsplash/plugins': patch
---

Fixes a bug where the BaseServiceV2 was erroring when parsing command line args from the Hardhat plugin
9 changes: 9 additions & 0 deletions packages/plugins/src/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Removes all command line args in the `process.argv` array that begin with '--'. This is necessary
* to prevent an error that occurs when running the executor from within a Hardhat plugin task. This
* error occurs because the BaseServiceV2 (inherited by the executor) parses these command line
* arguments and throws an error when it sees arguments that it does not recognize.
*/
export const removeFlagsFromCommandLineArgs = (): void => {
process.argv = process.argv.filter((arg) => !arg.startsWith('--'))
}
4 changes: 4 additions & 0 deletions packages/plugins/src/hardhat/deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
monitorTask,
TASK_CHUGSPLASH_VERIFY_BUNDLE,
} from './tasks'
import { removeFlagsFromCommandLineArgs } from '../env'

/**
* TODO
Expand Down Expand Up @@ -207,6 +208,9 @@ export const deployChugSplashConfig = async (
value: ethers.utils.parseEther('1'),
})

// We must remove the command line arguments that begin with '--' from the process.argv array,
// or else the BaseServiceV2 (inherited by the executor) will throw an error.
removeFlagsFromCommandLineArgs()
const executor = new ChugSplashExecutor()
await executor.main(
{
Expand Down
1 change: 1 addition & 0 deletions packages/plugins/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './hardhat'
export * from './messages'
export * from './env'

0 comments on commit a5af6ab

Please sign in to comment.