Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filename grouping function #24

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
420 changes: 418 additions & 2 deletions .gitignore

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ The options are the same as what's supported by `SketchTool`.
- `saveForWeb`: Export web-ready images (optional, defaults to NO).
- `compact`: Export in compact form. Currently only relevant for SVG export. (optional, defaults to NO).
- `trimmed`: Export images trimmed. (optional, defaults to NO).
- `filenameGrouping`: Add filename as folder to destination path. (optional, defaults to NO).

Additionally, it has `clean` option for exporting SVG.

Expand Down
4 changes: 4 additions & 0 deletions coffee/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ module.exports = (options = {}) ->
args.push '--bounds=' + options.bounds if options.bounds

options.clean = yesOrNo options.clean
options.filenameGroups = yesOrNo options.filenameGroups

through.obj (file, encoding, callback) ->
# stream?
Expand All @@ -71,6 +72,7 @@ module.exports = (options = {}) ->
# file_name.sketch is a file (>3.1)

src = file.path
{name: group} = path.parse file.path
tmp_dir = new temporary.Dir()

# Output JSON
Expand All @@ -90,6 +92,8 @@ module.exports = (options = {}) ->
recursive tmp_dir.path, (err, files) =>
for abs_path in files
rel_path = path.relative tmp_dir.path, abs_path
if options.filenameGrouping
rel_path = path.join group, rel_path
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An indent is supposed to be 2 spaces. Or:

rel_path = path.join group, rel_path if options.filenameGrouping

f = new gutil.File
cwd: file.cwd
base: file.base
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gulp-sketch",
"description": "SketchTool plugin for gulp",
"version": "1.0.3",
"version": "1.1.0",
"homepage": "https://github.com/cognitom/gulp-sketch",
"repository": {
"type": "git",
Expand Down
8 changes: 4 additions & 4 deletions test/expect/square-yellow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions test/expect/yellow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/fixtures/flat.sketch
Binary file not shown.
Binary file modified test/fixtures/subdir.sketch
Binary file not shown.