UNPKG

4.09 kBJavaScriptView Raw
1/*global module:false*/
2module.exports = function (grunt) {
3
4 // Project configuration.
5 grunt.initConfig({
6 // Metadata.
7 pkg: grunt.file.readJSON('package.json'),
8 banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
9 '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
10 '<%= pkg.repository.url%> */',
11
12 // Task configuration.
13 exec: {
14 generate: {
15 cmd: 'node generate/generate.js'
16 },
17 gzSize: {
18 cmd: 'cat mobile-detect.min.js | gzip -9f | wc -c'
19 }
20 },
21 jasmine_node: {
22 specNameMatcher: "spec", // load only specs containing specNameMatcher
23 projectRoot: ".",
24 requirejs: false,
25 forceExit: true,
26 jUnit: {
27 report: false,
28 savePath: "./build/reports/jasmine/",
29 useDotNotation: true,
30 consolidate: true
31 }
32 },
33 uglify: {
34 options: {
35 banner: '<%= banner %>'
36 },
37 dist: {
38 src: 'mobile-detect.js',
39 dest: 'mobile-detect.min.js'
40 }
41 },
42 jshint: {
43 options: {
44 curly: true,
45 eqeqeq: true,
46 immed: true,
47 latedef: true,
48 newcap: true,
49 noarg: true,
50 sub: true,
51 undef: true,
52 unused: true,
53 boss: true,
54 eqnull: true,
55 browser: true,
56 globals: {
57 jQuery: true,
58 Backbone: true,
59 Modernizr: true,
60 Mustache: true,
61 App: true,
62 console: true,
63 _: true
64 }
65 },
66 gruntfile: {
67 src: 'Gruntfile.js'
68 },
69 lib_test: {
70 src: ['generate/mobile-detect.template.js', 'tests/spec/*.js']
71 }
72 },
73 jsdoc: {
74 dist: {
75 src: ['<%= uglify.dist.src %>'],
76 options: {
77 destination: '../mobile-detect.js@gh-pages/doc',
78 //template: "default",
79 encoding: "utf8",
80 "private": false,
81 lenient: true
82 }
83 }
84 },
85 watch: {
86 gruntfile: {
87 files: '<%= jshint.gruntfile.src %>',
88 tasks: ['jshint:gruntfile']
89 },
90 lib_test: {
91 files: '<%= jshint.lib_test.src %>',
92 tasks: ['jshint:lib_test', 'jasmine_node']
93 }
94 },
95 copy: {
96 jsdelivr: {
97 files: [
98 {
99 expand: true,
100 src: [
101 'mobile-detect.min.js',
102 'mobile-detect.js',
103 'mobile-detect-modernizr.js'
104 ],
105 dest: '../jsdelivr/files/mobile-detect.js/<%= pkg.version %>/'
106 }
107 ]
108 }
109 }
110 });
111
112 // These plugins provide necessary tasks.
113 grunt.loadNpmTasks('grunt-contrib-uglify');
114 grunt.loadNpmTasks('grunt-contrib-jshint');
115 grunt.loadNpmTasks('grunt-contrib-watch');
116 grunt.loadNpmTasks('grunt-exec');
117 grunt.loadNpmTasks('grunt-jsdoc');
118 grunt.loadNpmTasks('grunt-jasmine-node');
119 grunt.loadNpmTasks('grunt-contrib-copy');
120
121 // Default task.
122 grunt.registerTask('default', ['jshint', 'exec:generate', 'jasmine_node', 'uglify', 'exec:gzSize']);
123 grunt.registerTask('skip-tests', ['jshint', 'exec:generate', 'uglify', 'exec:gzSize']);
124 grunt.registerTask('dev', ['jshint']);
125 grunt.registerTask('gh-pages', ['jshint', 'exec:generate', 'jsdoc']);
126 grunt.registerTask('jsdelivr', ['copy:jsdelivr']);
127};