1 | /* |
---|
2 | * grunt-http |
---|
3 | * https://github.com/johngeorgewright/grunt-contrib-http |
---|
4 | * |
---|
5 | * Copyright (c) 2013 John Wright |
---|
6 | * Licensed under the MIT license. |
---|
7 | */ |
---|
8 | |
---|
9 | 'use strict'; |
---|
10 | |
---|
11 | module.exports = function(grunt) { |
---|
12 | |
---|
13 | // Project configuration. |
---|
14 | grunt.initConfig({ |
---|
15 | jshint: { |
---|
16 | all: [ |
---|
17 | 'Gruntfile.js', |
---|
18 | 'tasks/*.js', |
---|
19 | '<%= nodeunit.tests %>', |
---|
20 | ], |
---|
21 | options: { |
---|
22 | jshintrc: '.jshintrc', |
---|
23 | }, |
---|
24 | }, |
---|
25 | |
---|
26 | // Before generating any new files, remove any previously-created files. |
---|
27 | clean: { |
---|
28 | tests: ['tmp'], |
---|
29 | }, |
---|
30 | |
---|
31 | // Configuration to be run (and then tested). |
---|
32 | http: { |
---|
33 | basic: { |
---|
34 | options: { |
---|
35 | url: 'http://www.j-g-w.info' |
---|
36 | }, |
---|
37 | dest: 'tmp/basic.html' |
---|
38 | }, |
---|
39 | closure: { |
---|
40 | options: { |
---|
41 | form: { |
---|
42 | output_info: 'compiled_code', |
---|
43 | output_format: 'text', |
---|
44 | compilation_level: 'SIMPLE_OPTIMIZATIONS', |
---|
45 | warning_level: 'default', |
---|
46 | }, |
---|
47 | url: 'http://closure-compiler.appspot.com/compile', |
---|
48 | method: 'POST', |
---|
49 | sourceField: 'form.js_code' |
---|
50 | }, |
---|
51 | files: { |
---|
52 | 'tmp/compiled.js': 'test/fixtures/not-compiled.js' |
---|
53 | } |
---|
54 | }, |
---|
55 | ignoreErrors: { |
---|
56 | options: { |
---|
57 | url: 'http://someurlthatdoesntexist.xx', |
---|
58 | method: 'GET', |
---|
59 | ignoreErrors: true |
---|
60 | } |
---|
61 | } |
---|
62 | }, |
---|
63 | |
---|
64 | // Unit tests. |
---|
65 | nodeunit: { |
---|
66 | tests: ['test/*_test.js'], |
---|
67 | }, |
---|
68 | |
---|
69 | }); |
---|
70 | |
---|
71 | // Actually load this plugin's task(s). |
---|
72 | grunt.loadTasks('tasks'); |
---|
73 | |
---|
74 | // These plugins provide necessary tasks. |
---|
75 | grunt.loadNpmTasks('grunt-contrib-jshint'); |
---|
76 | grunt.loadNpmTasks('grunt-contrib-clean'); |
---|
77 | grunt.loadNpmTasks('grunt-contrib-nodeunit'); |
---|
78 | |
---|
79 | // Whenever the "test" task is run, first clean the "tmp" dir, then run this |
---|
80 | // plugin's task(s), then test the result. |
---|
81 | grunt.registerTask('test', ['clean', 'http', 'nodeunit']); |
---|
82 | |
---|
83 | // By default, lint and run all tests. |
---|
84 | grunt.registerTask('default', ['jshint', 'test']); |
---|
85 | |
---|
86 | }; |
---|