UNPKG

3.49 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 jshintrc: '.jshintrc'
45 },
46 gruntfile: {
47 src: 'Gruntfile.js'
48 },
49 lib_test: {
50 src: ['generate/mobile-detect.template.js', 'tests/spec/*.js']
51 }
52 },
53 jsdoc: {
54 dist: {
55 src: ['<%= uglify.dist.src %>'],
56 options: {
57 destination: '../mobile-detect.js@gh-pages/doc',
58 //template: "default",
59 encoding: "utf8",
60 "private": false,
61 lenient: true
62 }
63 }
64 },
65 watch: {
66 gruntfile: {
67 files: '<%= jshint.gruntfile.src %>',
68 tasks: ['jshint:gruntfile']
69 },
70 lib_test: {
71 files: '<%= jshint.lib_test.src %>',
72 tasks: ['jshint:lib_test', 'jasmine_node']
73 }
74 },
75 copy: {
76 jsdelivr: {
77 files: [
78 {
79 expand: true,
80 src: [
81 'mobile-detect.min.js',
82 'mobile-detect.js',
83 'mobile-detect-modernizr.js'
84 ],
85 dest: '../jsdelivr/files/mobile-detect.js/<%= pkg.version %>/'
86 }
87 ]
88 }
89 }
90 });
91
92 // These plugins provide necessary tasks.
93 grunt.loadNpmTasks('grunt-contrib-uglify');
94 grunt.loadNpmTasks('grunt-contrib-jshint');
95 grunt.loadNpmTasks('grunt-contrib-watch');
96 grunt.loadNpmTasks('grunt-exec');
97 grunt.loadNpmTasks('grunt-jsdoc');
98 grunt.loadNpmTasks('grunt-jasmine-node');
99 grunt.loadNpmTasks('grunt-contrib-copy');
100
101 // Default task.
102 grunt.registerTask('default', ['jshint', 'exec:generate', 'jasmine_node', 'uglify', 'exec:gzSize']);
103 grunt.registerTask('skip-tests', ['jshint', 'exec:generate', 'uglify', 'exec:gzSize']);
104 grunt.registerTask('dev', ['jshint']);
105 grunt.registerTask('gh-pages', ['jshint', 'exec:generate', 'jsdoc']);
106 grunt.registerTask('jsdelivr', ['copy:jsdelivr']);
107};