wheelhouse-handlebars
Version:
A wheelhouse library to handlebars templates for rendering views
136 lines (130 loc) • 3.72 kB
JavaScript
'use strict';
module.exports = function(grunt){
grunt.initConfig({
pkg: grunt.file.readJSON('package.json')
, meta: {
version: '<%= pkg.version %>'
, banner: '/*! <%= pkg.name %> - v<%= meta.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n'
}
, jshint: {
all: [
'Gruntfile.js'
, 'index.js'
, 'lib/**/*.js'
, 'test/**/*.js'
]
, options: {
jshintrc: '.jshintrc'
}
}
, bump: {
patch: {
options: {
part: 'patch'
, tabSize: 2
}
, src: [
'package.json'
]
}
, minor: {
options: {
part: 'minor'
, tabSize: 2
}
, src: '<%= bump.patch.src %>'
}
, major: {
options: {
part: 'major'
, tabSize: 2
}
, src: '<%= bump.patch.src %>'
}
}
, simplemocha: {
options: {
timeout: 2000
, ignoreLeaks: true
, ui: 'bdd'
}
, all: {
src: ['test/specs/**/*.js']
}
}
, shell: {
gitTag: {
command: 'git tag v<%= grunt.file.readJSON("package.json").version %>'
, options: {
stdout: true
, failOnError: true
}
}
, gitRequireCleanTree: {
command: 'function require_clean_work_tree(){\n' +
' # Update the index\n' +
' git update-index -q --ignore-submodules --refresh\n' +
' err=0\n' +
' # Disallow unstaged changes in the working tree\n' +
' if ! git diff-files --quiet --ignore-submodules --\n' +
' then\n' +
' echo >&2 "cannot $1: you have unstaged changes."\n' +
' git diff-files --name-status -r --ignore-submodules -- >&2\n' +
' err=1\n' +
' fi\n' +
' # Disallow uncommitted changes in the index\n' +
' if ! git diff-index --cached --quiet HEAD --ignore-submodules --\n' +
' then\n' +
' echo >&2 "cannot $1: your index contains uncommitted changes."\n' +
' git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2\n' +
' err=1\n' +
' fi\n' +
' if [ $err = 1 ]\n' +
' then\n' +
' echo >&2 "Please commit or stash them."\n' +
' exit 1\n' +
' fi\n' +
'} \n require_clean_work_tree'
, options: {
failOnError: true
}
}
, gitCommitPackage: {
command: 'git commit --amend -i package.json --reuse-message HEAD'
, options: {
stdout: true
, failOnError: true
}
}
, gitPush: {
command: 'git push origin master --tags'
, options: {
stdout: true
, failOnError: true
}
}
, npmPublish: {
command: 'npm publish'
, options: {
stdout: true
, failOnError: true
}
}
, npmTest: {
command: 'npm test'
, options: {
stdout: true
, failOnError: true
}
}
}
})
grunt.loadNpmTasks('grunt-contrib-jshint')
grunt.loadNpmTasks('grunt-simple-mocha')
grunt.loadNpmTasks('grunt-notify')
grunt.loadNpmTasks('grunt-shell')
grunt.loadNpmTasks('grunt-bumpx')
grunt.registerTask('test', ['simplemocha'])
grunt.registerTask('publish', ['shell:gitRequireCleanTree', 'jshint', 'shell:npmTest', 'bump:' + (grunt.option('bump') || 'patch'), 'shell:gitCommitPackage', 'shell:gitTag', 'shell:gitPush', 'shell:npmPublish'])
}