priority-ignore/grunt.js

131 lines
3.7 KiB
JavaScript
Raw Normal View History

2012-07-09 20:16:06 +00:00
/* mode:javascript; tab-width:2; indent-tabs-mode:nil; */
/*global module:false*/
path = require('path');
_und = require('underscore');
2012-07-09 21:36:08 +00:00
2012-07-09 20:16:06 +00:00
module.exports = function(grunt) {
2012-07-09 21:36:08 +00:00
grunt.loadNpmTasks('grunt-coffee');
grunt.loadNpmTasks('grunt-recess');
2012-07-09 20:16:06 +00:00
// Project configuration.
grunt.initConfig({
pkg: '<json:PriorityIgnore.json>',
meta: {
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
},
qunit: {
files: ['test/**/*.html']
},
lint: {
files: ['grunt.js', 'src/**/*.js', 'test/**/*.js']
},
watch: {
files: '<config:lint.files>',
tasks: 'lint qunit'
},
server: {
port: 8081,
base: './dist/'
},
haml: {
src: ['src/**/*.haml'],
dest: './src/'
},
templatize: {
2012-07-09 21:36:08 +00:00
src: ['src/**/*_tmpl.html'],
2012-07-09 20:16:06 +00:00
dest: './src'
},
2012-07-09 21:36:08 +00:00
coffee: {
dev: {
src: ['src/**/*.coffee'],
dest: 'src',
options: {
bare: false
}
}
},
2012-07-09 20:16:06 +00:00
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
browser: true
},
globals: {
jQuery: true
}
},
2012-07-09 21:36:08 +00:00
recess: {
dev: {
src: ['src/style.less'],
dest: 'src/style.css',
options: {
compile: true
}
}
},
2012-07-09 20:16:06 +00:00
uglify: {}
});
// Default task.
grunt.registerTask('default', 'lint qunit concat min');
grunt.registerHelper('haml', function(src, dest, done) {
var args = {
cmd: 'haml',
args: ["--unix-newlines", "--no-escape-attrs", "--double-quote-attributes", src]
}
grunt.utils.spawn(args, function(err, result) {
var out = path.basename(src, '.haml');
grunt.file.write(path.join(dest, out + '.html'), result.stdout)
done()
});
});
grunt.registerTask('haml', 'Compile HAML', function() {
var done = this.async(),
sources = grunt.file.expandFiles(grunt.config([this.name, 'src'])),
dest = grunt.config([this.name, 'dest']);
sources.forEach(function(path) {
grunt.helper('haml', path, dest, done);
});
});
grunt.registerHelper('templatize', function(src, dest, done) {
var file = grunt.file.read(src);
console.log('define(' + _und.template(file).source + ');');
done();
});
grunt.registerTask('templatize', 'Compile Underscored HTML to Javascript', function() {
var done = this.async(),
sources = grunt.file.expandFiles(grunt.config([this.name, 'src'])),
dest = grunt.config([this.name, 'dest']);
2012-07-09 21:36:08 +00:00
if (sources.length == 0)
return done();
2012-07-09 20:16:06 +00:00
sources.forEach(function(path) {
grunt.helper('templatize', path, dest, done);
});
});
2012-07-09 21:36:08 +00:00
grunt.registerTask('dev', 'coffee:dev recess:dev templatize haml');
2012-07-09 20:16:06 +00:00
};