Skip to content

Commit

Permalink
Add grunt task for building docs screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
eternicode committed Jan 31, 2014
1 parent da25869 commit 8bc254a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
27 changes: 26 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,31 @@ module.exports = function(grunt){

grunt.registerTask('lint', 'Lint all js files with jshint and jscs', ['jshint', 'jscs']);
grunt.registerTask('test', 'Lint files and run unit tests', ['lint', 'qunit']);
grunt.registerTask('finish', 'Prepares repo for commit [test, less:repo]', ['test', 'less:repo']);
grunt.registerTask('finish', 'Prepares repo for commit [test, less:repo, screenshots]', ['test', 'less:repo', 'screenshots']);
grunt.registerTask('dist', 'Builds minified files', ['less:css', 'less:standalone', 'cssmin', 'uglify']);

grunt.registerTask('screenshots', 'Rebuilds automated docs screenshots', function(){
var phantomjs = require('phantomjs').path;

grunt.file.recurse('docs/_static/screenshots/', function(abspath){
grunt.file.delete(abspath);
});

grunt.file.recurse('docs/_screenshots/', function(abspath, root, subdir, filename){
if (!/.html$/.test(filename))
return;
subdir = subdir || '';

var outdir = "docs/_static/screenshots/" + subdir,
outfile = outdir + filename.replace(/.html$/, '.png');

if (!grunt.file.exists(outdir))
grunt.file.mkdir(outdir);

grunt.util.spawn({
cmd: phantomjs,
args: ['docs/_screenshots/script/screenshot.js', abspath, outfile]
});
});
});
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"grunt-contrib-less": "~0.9.0",
"grunt-contrib-uglify": "~0.2.7",
"grunt-contrib-cssmin": "~0.7.0",
"grunt-contrib-clean": "~0.5.0"
"grunt-contrib-clean": "~0.5.0",
"phantomjs": "~1.9.0"
}
}

0 comments on commit 8bc254a

Please sign in to comment.