Skip to content

Commit 238f950

Browse files
committed
move export config to .sketchrc
1 parent e5291fd commit 238f950

15 files changed

Lines changed: 119 additions & 40 deletions

.editorconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2

.eslintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ parserOptions:
99
ecmaVersion: 2017
1010
sourceType: module
1111
ecmaFeatures:
12-
experimentalObjectRestSpread: true
1312
jsx: true

.gitsketchrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"exportFolder": ".exportedArtboards",
3+
"exportFormat": "png",
4+
"exportScale": "0.5",
5+
"includeOverviewFile": false
6+
}

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## [0.10.0] - 2017-04-11
2+
3+
* move export config to `.gitsketchrc` so that everybody working
4+
on the same file will have the same settings
5+
* fix the default config which could be break sometimes
6+
* fix exporting artboards when there is a space in the path to Sketch
7+
8+
19
## [0.9.2] - 2017-04-06
210

311
* Added support for multiple file formats (png, jpg, pdf, eps, svg)

Git.sketchplugin/exportArtboard.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
set -e -o pipefail
23

34
DIR_PATH="$1"
45
EXPORT_FOLDER="$2"
@@ -11,22 +12,22 @@ INCLUDE_OVERVIEW="$8"
1112

1213

1314
cd "$DIR_PATH"
14-
mkdir -p "$EXPORT_FOLDER"
15+
mkdir -p "$EXPORT_FOLDER" || true
1516

1617
# move old artboards to temp directory to compare them with the new ones
17-
rm -rf .oldArtboards
18-
mv "$FILE_FOLDER" .oldArtboards 2>/dev/null
18+
rm -rf .oldArtboards || true
19+
mv "$FILE_FOLDER" .oldArtboards || true
1920

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

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

2627

2728
# generate new artboards
2829
mkdir -p "$FILE_FOLDER"
29-
$BUNDLE_PATH/Contents/Resources/sketchtool/bin/sketchtool export artboards "$FILENAME" --formats="$FORMAT" --scales="$SCALE" --output="$FILE_FOLDER" --overwriting=YES --items="$ARTBOARDS" --include-symbols=YES
30+
"$BUNDLE_PATH"/Contents/Resources/sketchtool/bin/sketchtool export artboards "$FILENAME" --formats="$FORMAT" --scales="$SCALE" --output="$FILE_FOLDER" --overwriting=YES --items="$ARTBOARDS" --include-symbols=YES
3031

3132
# Construct a ${FILENAME}-boards.md file which shows all the artboards in the sketch directory
3233
if [[ ${INCLUDE_OVERVIEW} == "true" ]]

example/example-boards.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Artboards
2+
3+
This is an autogenerated file showing all the artboards. Do not edit it directly.
4+
5+
## Artboard 1@0.5x
6+
7+
![Artboard 1@0.5x](./.exportedArtboards/example/Artboard 1@0.5x.png)
8+
9+
10+
## Rectangle@0.5x
11+
12+
![Rectangle@0.5x](./.exportedArtboards/example/Rectangle@0.5x.png)
13+

example/example.sketch

-38.2 KB
Binary file not shown.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@
4747
"eslint-config-standard-preact": "1.0.1",
4848
"eslint-plugin-react": "6.10.3",
4949
"preact": "^7.1.0",
50+
"sketch-module-fs": "0.1.2",
5051
"sketch-module-google-analytics": "^0.1.3",
5152
"sketch-module-update": "^0.1.2",
52-
"sketch-module-user-preferences": "^0.2.3",
53+
"sketch-module-user-preferences": "1.0.1",
5354
"sketch-module-web-view": "0.1.4"
5455
}
5556
}

src/analytics.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { getUserPreferences } from './preferences'
44
const key = 'UA-88206962-1'
55

66
export function sendEvent (context, category, action, label, value) {
7-
const { sendAnalytics } = getUserPreferences()
7+
const { sendAnalytics } = getUserPreferences(context)
88
if (!sendAnalytics) { return }
99
const payload = {}
1010
if (category) { payload.ec = category }
@@ -16,7 +16,7 @@ export function sendEvent (context, category, action, label, value) {
1616
}
1717

1818
export function sendError (context, error) {
19-
const { sendAnalytics } = getUserPreferences()
19+
const { sendAnalytics } = getUserPreferences(context)
2020
if (!sendAnalytics) { return }
2121
return send(context, key, 'event', {exd: error})
2222
}

src/commands/Commit.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ export default function (context) {
88
executeSafely(context, function () {
99
sendEvent(context, 'Commit', 'Start commiting')
1010
var currentBranch = getCurrentBranch(context)
11-
var commitMsg = createInputWithCheckbox(context, 'Commit to "' + currentBranch + '"', 'Generate files for pretty diffs', getUserPreferences().diffByDefault, 'Commit')
11+
const prefs = getUserPreferences(context)
12+
var commitMsg = createInputWithCheckbox(context, 'Commit to "' + currentBranch + '"', 'Generate files for pretty diffs', prefs.diffByDefault, 'Commit')
1213

1314
if (commitMsg.responseCode == 1000 && commitMsg.message != null) {
1415
if (commitMsg.checked) {
1516
sendEvent(context, 'Commit', 'Export artboards')
16-
exportArtboards(context)
17+
exportArtboards(context, prefs)
1718
}
1819
sendEvent(context, 'Commit', 'Do commit')
1920
var command = `git commit -m "${commitMsg.message.split('"').join('\\"')}" -a; exit`

0 commit comments

Comments
 (0)