/
backbonebuilder.js
47 lines (37 loc) · 1.16 KB
/
backbonebuilder.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* grunt-backbonebuilder
* https://github.com/asciidisco/grunt-backbonebuilder
*
* Copyright (c) 2012 asciidisco
* Licensed under the MIT license.
*/
module.exports = function (grunt) {
'use strict';
// Internal lib
var builder = require('../lib/builder').init(grunt);
// ==========================================================================
// TASKS
// ==========================================================================
grunt.registerTask('backbone', 'Builds your custimized backbone experience', function(mode) {
var done = this.async(),
config = grunt.config.get('backbone');
var fileWriter = function (transport, options) {
// display error
if (transport.type === 'error') {
grunt.log.error(transport.content);
}
// proceed with file content
if (transport.type === 'content') {
grunt.log.write('Writing custom Backbone file');
grunt.file.write(options.config.dest, transport.content);
}
options.done();
};
// execute clear target helper
builder.build({
config: config,
done: done,
debug: !!config.debug
}, fileWriter);
});
};