Skip to content

Instantly share code, notes, and snippets.

@johnnieskywalker
Created May 11, 2023 09:10
Show Gist options
  • Save johnnieskywalker/7bcd85e99519475668ae843058abf7d1 to your computer and use it in GitHub Desktop.
Save johnnieskywalker/7bcd85e99519475668ae843058abf7d1 to your computer and use it in GitHub Desktop.
Flatten all files from contracts folder and save to flattened directory
#!/bin/bash
CONTRACTS_DIR="./contracts"
FLATTENED_DIR="./flattened"
mkdir -p "$FLATTENED_DIR"
for FILE in "${CONTRACTS_DIR}"/*.sol; do
if [[ -f "$FILE" ]] && [[ -r "$FILE" ]]; then
FILE_NAME="$(basename "${FILE%.sol}")"
npx hardhat flatten "${FILE}" > "${FLATTENED_DIR}/${FILE_NAME}_flattened.sol"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment