Skip to content

Instantly share code, notes, and snippets.

@kennethlynne
Last active April 16, 2016 23:58
Show Gist options
  • Save kennethlynne/30dafef6ff2f3bb2ea6babd08fea364a to your computer and use it in GitHub Desktop.
Save kennethlynne/30dafef6ff2f3bb2ea6babd08fea364a to your computer and use it in GitHub Desktop.
export png from artboards and slices in sketch
var gulp = require('gulp');
var sketch = require('gulp-sketch');
var argv = require('yargs').argv;
var del = require('del');
var runSequence = require('run-sequence');
var outputDir = './output/';
if (!argv && argv.path) {
throw new Error('path argument missing');
}
var inputGlob = argv.path;
gulp.task('clean', function () {
del([outputDir + '/**/*']);
});
gulp.task('exportSlices', function () {
return gulp.src(inputGlob)
.pipe(sketch({
export: 'slices',
formats: 'png'
}))
.pipe(gulp.dest(outputDir));
});
gulp.task('exportArtboards', function () {
return gulp.src(inputGlob)
.pipe(sketch({
export: 'artboards',
formats: 'png'
}))
.pipe(gulp.dest(outputDir));
});
gulp.task('default', ['export'], function () {
gulp.watch(inputGlob, ['export']);
});
gulp.task('export', function (cb) {
runSequence(['clean', 'exportArtboards', 'exportSlices'], cb);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment