// Project configuration. grunt.initConfig({ lint: { files: ['lib/**/*.js', 'test/**/*.js', '! test/lib/**/*.js', 'www/js/**/*.js'] }, watch: { files: [ '<config:lint.files>', 'www/templates/*.tmpl' ], tasks: 'test' }, 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: { $ : true, _ : true, RSVP : true, app : true } }, uglify: {}, mocha: { index: [ 'test/runner/index.html' ] } }); grunt.registerTask('build-‐template-‐mocks', 'Build template mocks', function() { var obj = {}; var addFile = function(filepath, contents) { obj[ filepath.replace('templates/', '') ] = contents; }; var options = {cwd: 'www'}; grunt.file.expand(options, 'templates/*.tmpl').forEach(function(filepath) { addFile(filepath, grunt.file.read('www/' + filepath)); }); var src = 'window._templateMocks = ' + JSON.stringify(obj, null, 2) + ';'; grunt.file.write('test/fixtures/templates.js', src); }); grunt.loadNpmTasks('grunt-‐mocha'); grunt.registerTask('test', 'build-‐template-‐mocks mocha'); grunt.registerTask('default', 'lint test'); }; mocha: { index: [ 'test/runner/index.html' ] }