Slide 41
Slide 41 text
/*global
module:false*/
var
child_process
=
require('child_process');
module.exports
=
function(grunt)
{
//
Project
configuration.
grunt.initConfig({
lint:
{
files:
['lib/**/*.js',
'test/**/*.js',
'!
test/lib/**/*.js',
'www/js/**/*.js']
},
watch:
{
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');
};