Skip to content

Instantly share code, notes, and snippets.

@lajlev
Last active June 15, 2016 07:41
Show Gist options
  • Save lajlev/f5ee1e2e2e315f5274b10ec6d9ca93a0 to your computer and use it in GitHub Desktop.
Save lajlev/f5ee1e2e2e315f5274b10ec6d9ca93a0 to your computer and use it in GitHub Desktop.

Revisions

  1. lajlev revised this gist Jun 15, 2016. 1 changed file with 11 additions and 5 deletions.
    16 changes: 11 additions & 5 deletions pre-commit
    Original file line number Diff line number Diff line change
    @@ -7,10 +7,16 @@
    # A: It creates a .exportArtboards folder with all artboards as PNGs,
    # so you easily can see changes in GIT 🎊.

    SKETCHFILES=$(git diff-index --cached HEAD | grep ".sketch" | grep "^:" | sed 's:.*[DAM][ \\''t]*\([^ \\''t]*\):\1:g');

    for FILE in $SKETCHFILES
    do
    sketchtool export artboards $FILE --output=".exportArtboards" --overwriting=YES --trimmed=NO --save-for-web=YES
    git add .exportArtboards
    git diff --cached --name-status | while read STATE FILE; do

    # Skip deleted files
    if [ "$STATE" == 'D' ]; then continue; fi

    # Do a check only on the sketch files files
    if [[ ${FILE: -7} == ".sketch" ]]; then
    DIR=$(dirname "${FILE}")
    sketchtool export artboards $FILE --output="${DIR}/.exportArtboards" --overwriting=YES --trimmed=NO --save-for-web=YES
    git add ${DIR}/.exportArtboards
    fi
    done
  2. lajlev created this gist Jun 14, 2016.
    16 changes: 16 additions & 0 deletions pre-commit
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #!/bin/sh
    # Requires sketch and Sketchtool

    # Q: How to enable it?
    # A: Add it to your repo pre-commit hook
    # Q: What does it do?
    # A: It creates a .exportArtboards folder with all artboards as PNGs,
    # so you easily can see changes in GIT 🎊.

    SKETCHFILES=$(git diff-index --cached HEAD | grep ".sketch" | grep "^:" | sed 's:.*[DAM][ \\''t]*\([^ \\''t]*\):\1:g');

    for FILE in $SKETCHFILES
    do
    sketchtool export artboards $FILE --output=".exportArtboards" --overwriting=YES --trimmed=NO --save-for-web=YES
    git add .exportArtboards
    done