1 | /* |
---|
2 | * grunt-contrib-coffee |
---|
3 | * http://gruntjs.com/ |
---|
4 | * |
---|
5 | * Copyright (c) 2012 Eric Woroshow, contributors |
---|
6 | * Licensed under the MIT license. |
---|
7 | */ |
---|
8 | |
---|
9 | 'use strict'; |
---|
10 | |
---|
11 | module.exports = function(grunt) { |
---|
12 | |
---|
13 | var mixedConcatFixtures = [ |
---|
14 | 'test/fixtures/coffee1.coffee', |
---|
15 | 'test/fixtures/coffee2.coffee', |
---|
16 | 'test/fixtures/litcoffee.litcoffee' |
---|
17 | ]; |
---|
18 | |
---|
19 | var uniformConcatFixtures = [ |
---|
20 | 'test/fixtures/coffee1.coffee', |
---|
21 | 'test/fixtures/coffee2.coffee' |
---|
22 | ]; |
---|
23 | |
---|
24 | // Project configuration. |
---|
25 | grunt.initConfig({ |
---|
26 | jshint: { |
---|
27 | all: [ |
---|
28 | 'Gruntfile.js', |
---|
29 | 'tasks/*.js', |
---|
30 | '<%= nodeunit.tests %>' |
---|
31 | ], |
---|
32 | options: { |
---|
33 | jshintrc: '.jshintrc' |
---|
34 | } |
---|
35 | }, |
---|
36 | |
---|
37 | // Before generating any new files, remove any previously-created files. |
---|
38 | clean: { |
---|
39 | tests: ['tmp/bare', 'tmp/default', 'tmp/join'] |
---|
40 | }, |
---|
41 | |
---|
42 | // Configuration to be run (and then tested). |
---|
43 | coffee: { |
---|
44 | compileDefault: { |
---|
45 | files: { |
---|
46 | 'tmp/default/coffee.js': ['test/fixtures/coffee1.coffee'], |
---|
47 | 'tmp/default/litcoffee.js': ['test/fixtures/litcoffee.litcoffee'], |
---|
48 | 'tmp/default/litcoffeemd.js': ['test/fixtures/litcoffee.coffee.md'], |
---|
49 | 'tmp/default/concat.js': mixedConcatFixtures |
---|
50 | } |
---|
51 | }, |
---|
52 | compileBare: { |
---|
53 | options: { |
---|
54 | bare: true |
---|
55 | }, |
---|
56 | files: { |
---|
57 | 'tmp/bare/coffee.js': ['test/fixtures/coffee1.coffee'], |
---|
58 | 'tmp/bare/litcoffee.js': ['test/fixtures/litcoffee.litcoffee'], |
---|
59 | 'tmp/bare/litcoffeemd.js': ['test/fixtures/litcoffee.coffee.md'], |
---|
60 | 'tmp/bare/concat.js': mixedConcatFixtures |
---|
61 | } |
---|
62 | }, |
---|
63 | compileJoined: { |
---|
64 | options: { |
---|
65 | join: true |
---|
66 | }, |
---|
67 | files: { |
---|
68 | 'tmp/join/coffee.js': ['test/fixtures/coffee1.coffee'], |
---|
69 | 'tmp/join/join.js': uniformConcatFixtures |
---|
70 | } |
---|
71 | }, |
---|
72 | compileBareJoined: { |
---|
73 | options: { |
---|
74 | bare: true, |
---|
75 | join: true |
---|
76 | }, |
---|
77 | files: { |
---|
78 | 'tmp/join/bareCoffee.js': ['test/fixtures/coffee1.coffee'], |
---|
79 | 'tmp/join/bareJoin.js': uniformConcatFixtures |
---|
80 | } |
---|
81 | }, |
---|
82 | compileMaps: { |
---|
83 | options: { |
---|
84 | sourceMap: true |
---|
85 | }, |
---|
86 | files: { |
---|
87 | 'tmp/maps/coffee.js': ['test/fixtures/coffee1.coffee'], |
---|
88 | 'tmp/maps/coffeeJoin.js': uniformConcatFixtures |
---|
89 | } |
---|
90 | }, |
---|
91 | compileEachMap: { |
---|
92 | options: { |
---|
93 | sourceMap: true |
---|
94 | }, |
---|
95 | files: [{ |
---|
96 | expand: true, |
---|
97 | cwd: 'test/fixtures/', |
---|
98 | src: ['coffee1.coffee', 'litcoffee.litcoffee'], |
---|
99 | dest: 'tmp/eachMap/', |
---|
100 | ext: '.js' |
---|
101 | }] |
---|
102 | }, |
---|
103 | compileBareMaps: { |
---|
104 | options: { |
---|
105 | sourceMap: true, |
---|
106 | bare: true |
---|
107 | }, |
---|
108 | files: { |
---|
109 | 'tmp/maps/coffeeBare.js': ['test/fixtures/coffee1.coffee'], |
---|
110 | 'tmp/maps/coffeeBareJoin.js': uniformConcatFixtures |
---|
111 | } |
---|
112 | } |
---|
113 | }, |
---|
114 | |
---|
115 | // Unit tests. |
---|
116 | nodeunit: { |
---|
117 | tests: ['test/*_test.js'] |
---|
118 | } |
---|
119 | }); |
---|
120 | |
---|
121 | // Actually load this plugin's task(s). |
---|
122 | grunt.loadTasks('tasks'); |
---|
123 | |
---|
124 | // These plugins provide necessary tasks. |
---|
125 | grunt.loadNpmTasks('grunt-contrib-jshint'); |
---|
126 | grunt.loadNpmTasks('grunt-contrib-clean'); |
---|
127 | grunt.loadNpmTasks('grunt-contrib-nodeunit'); |
---|
128 | grunt.loadNpmTasks('grunt-contrib-internal'); |
---|
129 | |
---|
130 | // Whenever the "test" task is run, first clean the "tmp" dir, then run this |
---|
131 | // plugin's task(s), then test the result. |
---|
132 | grunt.registerTask('test', ['clean', 'coffee', 'nodeunit']); |
---|
133 | |
---|
134 | // By default, lint and run all tests. |
---|
135 | grunt.registerTask('default', ['jshint', 'test', 'build-contrib']); |
---|
136 | |
---|
137 | }; |
---|