Skip to content

Commit

Permalink
flatten symlink (#2384)
Browse files Browse the repository at this point in the history
Co-authored-by: Trajan0x <[email protected]>
  • Loading branch information
trajan0x and trajan0x authored Mar 28, 2024
1 parent 914561c commit 907ca74
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 99 deletions.
33 changes: 33 additions & 0 deletions make/scripts/flatten.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
# This script flattens Solidity contracts and saves them in ./flattened
# The existing content of ./flattened is removed
# This tool takes both globs and filenames as the list of arguments and flattens everything
# Usage: ./script/sh/flatten.sh contracts/**.sol contracts/client/TestClient.sol <...>

RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color

# Check if arguments were supplied
if [ $# -eq 0 ]; then
echo -e "${RED}Error: provide globs/filenames of the contracts to flatten!${NC}"
exit 1
fi

# First, we remove the existing flattened files
rm -rf ./flattened

# Track the amount of flattened files for the final report
count=0
# Then, we iterate over the supplied arguments
# If any argument was a glob, this will iterate over the files it specifies
for var in "$@"; do
# Strip contract name "Abc.sol" from the path
fn=$(basename "$var")
# Flatten the file and save it in ./flattened
# Make sure that flattened contracts base names are unique!
forge flatten "$var" -o "./flattened/$fn"
((++count))
done

echo -e "${GREEN}Files flattened: $count${NC}"
33 changes: 0 additions & 33 deletions packages/contracts-communication/flatten.sh

This file was deleted.

1 change: 1 addition & 0 deletions packages/contracts-communication/flatten.sh
33 changes: 0 additions & 33 deletions packages/contracts-core/script/sh/flatten.sh

This file was deleted.

1 change: 1 addition & 0 deletions packages/contracts-core/script/sh/flatten.sh
33 changes: 0 additions & 33 deletions packages/contracts-rfq/flatten.sh

This file was deleted.

1 change: 1 addition & 0 deletions packages/contracts-rfq/flatten.sh

0 comments on commit 907ca74

Please sign in to comment.