|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +module.exports = function (grunt){ |
| 4 | + // Project configuration. |
| 5 | + grunt.initConfig({ |
| 6 | + pkg: grunt.file.readJSON('package.json'), |
| 7 | + |
| 8 | + jshint: { |
| 9 | + all: [ |
| 10 | + 'Gruntfile.js' |
| 11 | + , 'lib/**/*.js' |
| 12 | + , 'plugins/jquery.fileapi.js' |
| 13 | + ], |
| 14 | + |
| 15 | + options: { |
| 16 | + curly: true // + "Expected '{' and instead saw 'XXXX'." |
| 17 | + , immed: true |
| 18 | + , latedef: true |
| 19 | + , newcap: true // "Tolerate uncapitalized constructors" |
| 20 | + , noarg: true |
| 21 | + , sub: true |
| 22 | + , undef: true |
| 23 | + , unused: true |
| 24 | + , boss: true |
| 25 | + , eqnull: true |
| 26 | + |
| 27 | + , node: true |
| 28 | + , es5: true |
| 29 | + , expr: true // - "Expected an assignment or function call and instead saw an expression." |
| 30 | + , supernew: true // - "Missing '()' invoking a constructor." |
| 31 | + , laxcomma: true |
| 32 | + , laxbreak: true |
| 33 | + , smarttabs: true |
| 34 | + } |
| 35 | + }, |
| 36 | + |
| 37 | + qunit: { |
| 38 | + options: { |
| 39 | + files: { |
| 40 | + '1px.gif': ['tests/files/1px.gif'] |
| 41 | + , 'hello.txt': ['tests/files/hello.txt'] |
| 42 | + , 'image.jpg': ['tests/files/image.jpg'] |
| 43 | + , 'dino.png': ['tests/files/dino.png'] |
| 44 | + , 'multiple': ['tests/files/1px.gif', 'tests/files/hello.txt', 'tests/files/image.jpg', 'tests/files/dino.png', 'tests/files/lebowski.json'] |
| 45 | + } |
| 46 | + }, |
| 47 | + all: ['tests/*.html'] |
| 48 | + }, |
| 49 | + |
| 50 | + concat: { |
| 51 | + options: { |
| 52 | + banner: '/*! <%= pkg.name %> <%= pkg.version %> - <%= pkg.license %> | <%= pkg.repository.url %>\n' + |
| 53 | + ' * <%= pkg.description %>\n' + |
| 54 | + ' */\n\n', |
| 55 | + |
| 56 | + footer: 'if( typeof define === "function" && define.amd ){ define("FileAPI", [], function (){ return FileAPI; }); }' |
| 57 | + }, |
| 58 | + |
| 59 | + all: { |
| 60 | + src: [ |
| 61 | + 'lib/canvas-to-blob.js' |
| 62 | + , 'lib/FileAPI.core.js' |
| 63 | + , 'lib/FileAPI.Image.js' |
| 64 | + , 'lib/FileAPI.Form.js' |
| 65 | + , 'lib/FileAPI.XHR.js' |
| 66 | + , 'lib/FileAPI.Camera.js' |
| 67 | + , 'lib/FileAPI.Flash.js' |
| 68 | + ], |
| 69 | + dest: 'dist/<%= pkg.name %>.js' |
| 70 | + }, |
| 71 | + |
| 72 | + html5: { |
| 73 | + src: [ |
| 74 | + 'lib/canvas-to-blob.js' |
| 75 | + , 'lib/FileAPI.core.js' |
| 76 | + , 'lib/FileAPI.Image.js' |
| 77 | + , 'lib/FileAPI.Form.js' |
| 78 | + , 'lib/FileAPI.XHR.js' |
| 79 | + , 'lib/FileAPI.Camera.js' |
| 80 | + ], |
| 81 | + dest: 'dist/<%= pkg.name %>.html5.js' |
| 82 | + } |
| 83 | + }, |
| 84 | + |
| 85 | + uglify: { |
| 86 | + options: { banner: '/*! <%= pkg.name %> <%= pkg.version %> - <%= pkg.license %> | <%= pkg.repository.url %> */\n' }, |
| 87 | + dist: { |
| 88 | + files: { |
| 89 | + 'dist/<%= pkg.name %>.min.js': ['<%= concat.all.dest %>'] |
| 90 | + , 'dist/<%= pkg.name %>.html5.min.js': ['<%= concat.html5.dest %>'] |
| 91 | + , 'dist/jquery.fileapi.min.js': ['plugins/jquery.fileapi.js'] |
| 92 | + } |
| 93 | + } |
| 94 | + }, |
| 95 | + |
| 96 | + watch: { |
| 97 | + scripts: { |
| 98 | + files: 'lib/**/*.js', |
| 99 | + tasks: ['concat'], |
| 100 | + options: { interrupt: true } |
| 101 | + } |
| 102 | + } |
| 103 | + }); |
| 104 | + |
| 105 | + |
| 106 | + // These plugins provide necessary tasks. |
| 107 | + grunt.loadNpmTasks('grunt-contrib-jshint'); |
| 108 | + grunt.loadNpmTasks('grunt-contrib-concat'); |
| 109 | + grunt.loadNpmTasks('grunt-contrib-uglify'); |
| 110 | + grunt.loadNpmTasks('grunt-contrib-watch'); |
| 111 | + |
| 112 | + // Load custom QUnit task, based on grunt-contrib-qunit, but support "files" option. |
| 113 | + grunt.loadTasks('./tests/grunt-task/'); |
| 114 | + |
| 115 | + // "npm build" runs these tasks |
| 116 | + grunt.registerTask('build', ['concat', 'uglify', 'qunit']); |
| 117 | + grunt.registerTask('default', ['jshint', 'build']); |
| 118 | +}; |
0 commit comments