Skip to content

Commit

Permalink
find sketchignore in parent directories
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieudutour committed May 5, 2017
1 parent 2bc0708 commit f2aa0a5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
22 changes: 17 additions & 5 deletions Git.sketchplugin/exportArtboard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,30 @@ INCLUDE_OVERVIEW="$8"


cd "$DIR_PATH"
mkdir -p "$EXPORT_FOLDER" || true

# move old artboards to temp directory to compare them with the new ones
rm -rf .oldArtboards || true
mv "$FILE_FOLDER" .oldArtboards || true
function upsearch {
slashes=${PWD//[^\/]/}
directory="$PWD"
for (( n=${#slashes}; n>0; --n ))
do
test -e "$directory/$1" && echo "$directory/$1" && return
directory="$directory/.."
done
}

SKETCH_IGNORE=$(upsearch ".sketchignore")

# get list of artboards regex to ignore
IGNORE=$([ -e .sketchignore ] && (cat .sketchignore | sed '/^$/d' | sed 's/^/^/' | sed 's/$/$/' | tr '\n' ',') || echo "")
IGNORE=$([ -e "$SKETCH_IGNORE" ] && (cat "$SKETCH_IGNORE" | sed '/^$/d' | sed 's/^/^/' | sed 's/$/$/' | tr '\n' ',') || echo "")

# get list of artboard names to export
ARTBOARDS=$("$BUNDLE_PATH"/Contents/Resources/sketchtool/bin/sketchtool list artboards "$FILENAME" --include-symbols=YES | python "$(dirname "$0")"/getArtboardNames.py "$IGNORE" | tr '\n' ',')

mkdir -p "$EXPORT_FOLDER" || true

# move old artboards to temp directory to compare them with the new ones
rm -rf .oldArtboards || true
mv "$FILE_FOLDER" .oldArtboards || true

# generate new artboards
mkdir -p "$FILE_FOLDER"
Expand Down
2 changes: 1 addition & 1 deletion src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export function exportArtboards (context, prefs) {
const path = getCurrentDirectory(context)
const currentFileNameWithoutExtension = currentFileName.replace(/\.sketch$/, '')
const {exportFolder, exportFormat, exportScale, includeOverviewFile} = prefs
const pluginPath = context.scriptPath.replace(/Contents\/Sketch\/(\w*)\.js$/, '').replace(/ /g, '\\ ')
const pluginPath = context.scriptPath.replace(/\/Contents\/Sketch\/(\w*)\.js$/, '').replace(/ /g, '\\ ')
const bundlePath = NSBundle.mainBundle().bundlePath()
const fileFolder = exportFolder + '/' + currentFileNameWithoutExtension
const command = `${pluginPath}/exportArtboard.sh "${path}" "${exportFolder}" "${fileFolder}" "${bundlePath}" "${currentFileName}" "${exportFormat || 'png'}" "${exportScale}" "${includeOverviewFile}"`
Expand Down

0 comments on commit f2aa0a5

Please sign in to comment.