Skip to content

Instantly share code, notes, and snippets.

@mrice32
Created April 24, 2020 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrice32/def97e239f7bfc72f590c98f47b0d145 to your computer and use it in GitHub Desktop.
Save mrice32/def97e239f7bfc72f590c98f47b0d145 to your computer and use it in GitHub Desktop.
Flatten script
#!/usr/bin/env bash
# Must run from protocol/
# Usage: ./flatten.sh ~/SOME_TARGET_DIRECTORY
TARGET_DIR=$1
mkdir -p $TARGET_DIR
find ./core/contracts/ -name '*.sol' -type f -exec cp {} $TARGET_DIR \;
find ./node_modules/\@openzeppelin/contracts/ -name '*.sol' -type f -exec cp {} $TARGET_DIR \;
find $TARGET_DIR/ -type f -exec sed -i.bak "s/import \".*\/\([^/]*\.sol\)/import \".\/\1/g" {} \;
rm -rf $TARGET_DIR/*.bak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment