Skip to content

Instantly share code, notes, and snippets.

@mshustov
Last active August 29, 2015 14:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mshustov/7695c3351f95f44c9759 to your computer and use it in GitHub Desktop.
Save mshustov/7695c3351f95f44c9759 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Example usage:
# ./sgg.sh http://islands-components.incrop.lego-dev.dev.yandex-team.ru/ popup
GATHER_URL=${1:-https://lego-staging.dev.yandex-team.ru/islands-components/dev/}
BLOCK=$2
DIR_MAIN=gemini/screens
DIR_DIFF=gemini-report/diff
IMG_DIFF=./current-diff.png
HYSTERESIS=0.0005 #TODO parse from .gemini.yml
mkdir -p ${DIR_DIFF}
rm -rf ${DIR_DIFF}/*
if [ -n "$BLOCK" ]; then
mv ${DIR_MAIN}/${BLOCK} ${DIR_DIFF}
./node_modules/.bin/gemini gather --root-url=${GATHER_URL} gemini/${BLOCK}.gemini.js
else
mv ${DIR_MAIN}/* ${DIR_DIFF}
./node_modules/.bin/gemini gather --root-url=${GATHER_URL}
fi
pushd ${DIR_MAIN}
FILES="$(find . -type f | grep ^./${BLOCK})"
popd
echo "$FILES" | while read f; do
CMP_RESULT=$(gm compare -metric MSE -maximum-error ${HYSTERESIS} -file ${IMG_DIFF} "./$DIR_MAIN/$f" "./$DIR_DIFF/$f" 2>&1)
if [ 0 == "$?" ]; then
echo " same: $f"
mv "./$DIR_DIFF/$f" "./$DIR_MAIN/$f"
else
echo "different: $f"
optipng "./$DIR_MAIN/$f" -silent
mv -f ${IMG_DIFF} "./$DIR_DIFF/$f"
fi
done
rm -rf ${IMG_DIFF}
find ${DIR_DIFF} -type d -empty -delete
@arikon
Copy link

arikon commented Sep 2, 2014

В чём назначение этого скрипта?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment