Skip to content

Commit

Permalink
fix: Make update_metadata.sh work on macOS (google#5590)
Browse files Browse the repository at this point in the history
  • Loading branch information
gonfunko authored Oct 7, 2021
1 parent b25e24f commit 246927a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/scripts/update_metadata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,29 @@ blockly_size=$(wc -c < "build/blockly_compressed.js")
blocks_size=$(wc -c < "build/blocks_compressed.js")
blockly_gz_size=$(wc -c < "build/blockly_compressed.js.gz")
blocks_gz_size=$(wc -c < "build/blocks_compressed.js.gz")
quarter=$(date "+Q%q %Y")
quarters=(1 1 1 2 2 2 3 3 3 4 4 4)
month=$(date +%-m)
quarter=$(echo Q${quarters[$month - 1]} $(date +%Y))
version=$(npx -c 'echo "$npm_package_version"')

replacement="# ${quarter}\t${version}\t${blockly_size}\n"
replacement+="readonly BLOCKLY_SIZE_EXPECTED=${blockly_size}"
sed -ri "s/readonly BLOCKLY_SIZE_EXPECTED=[0-9]+/${replacement}/g" \
sed -ri.bak "s/readonly BLOCKLY_SIZE_EXPECTED=[0-9]+/${replacement}/g" \
tests/scripts/check_metadata.sh

replacement="# ${quarter}\t${version}\t${blocks_size}\n"
replacement+="readonly BLOCKS_SIZE_EXPECTED=${blocks_size}"
sed -ri "s/readonly BLOCKS_SIZE_EXPECTED=[0-9]+/${replacement}/g" \
sed -ri.bak "s/readonly BLOCKS_SIZE_EXPECTED=[0-9]+/${replacement}/g" \
tests/scripts/check_metadata.sh

replacement="# ${quarter}\t${version}\t${blockly_gz_size}\n"
replacement+="readonly BLOCKLY_GZ_SIZE_EXPECTED=${blockly_gz_size}"
sed -ri "s/readonly BLOCKLY_GZ_SIZE_EXPECTED=[0-9]+/${replacement}/g" \
sed -ri.bak "s/readonly BLOCKLY_GZ_SIZE_EXPECTED=[0-9]+/${replacement}/g" \
tests/scripts/check_metadata.sh

replacement="# ${quarter}\t${version}\t${blocks_gz_size}\n"
replacement+="readonly BLOCKS_GZ_SIZE_EXPECTED=${blocks_gz_size}"
sed -ri "s/readonly BLOCKS_GZ_SIZE_EXPECTED=[0-9]+/${replacement}/g" \
tests/scripts/check_metadata.sh
sed -ri.bak "s/readonly BLOCKS_GZ_SIZE_EXPECTED=[0-9]+/${replacement}/g" \
tests/scripts/check_metadata.sh

rm tests/scripts/check_metadata.sh.bak

0 comments on commit 246927a

Please sign in to comment.