-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Show a detailed error with next steps when cyclic dependencies are found * Add error handler on contract deployment task * Unified truffle flattener cyclic dependency errors * Add return and array to flatten call
- Loading branch information
1 parent
cc370b9
commit 2de4416
Showing
3 changed files
with
27 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const flatten = require('truffle-flattener') | ||
|
||
module.exports = async (sourcePaths) => { | ||
try { | ||
return flatten(sourcePaths) | ||
} catch (error) { | ||
const cycleDependencyErrorDetected = /cycle.+dependency/.test(error.message) | ||
if (cycleDependencyErrorDetected) { | ||
throw Error(`Cyclic dependencies in .sol files are not supported. | ||
'truffle-flattener' requires all cyclic dependencies to be resolved before proceeding. | ||
To do so, you can: | ||
- Remove unnecessary import statements, if any | ||
- Abstract the interface of imported contracts in a separate file | ||
- Merge multiple contracts in a single .sol file | ||
Original error: ${error} | ||
`) | ||
} else { | ||
throw error | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters