UNPKG

2.38 kBJavaScriptView Raw
1/*
2Copyright (c) 2015, Yahoo! Inc. All rights reserved.
3Copyrights licensed under the New BSD License.
4See the accompanying LICENSE file for terms.
5*/
6module.exports = function(grunt) {
7
8 grunt.initConfig({
9 pkg: grunt.file.readJSON('package.json'),
10 jshint: {
11 files: ['src/*.js'],
12 options: {
13 scripturl: true,
14 camelcase: true,
15 unused: true
16 }
17 },
18 jsdoc : {
19 dist : {
20 src: ['README.md', 'src/<%= pkg.name %>.js'],
21 options: {
22 destination: 'dist/docs',
23 template : 'node_modules/grunt-jsdoc/node_modules/ink-docstrap/template',
24 configure : 'jsdoc.conf.json'
25 }
26 }
27 },
28 browserify: {
29 standalone: {
30 src: [ 'src/<%= pkg.name %>.js' ],
31 dest: 'dist/<%= pkg.name %>.js',
32 options: {
33 browserifyOptions: {
34 standalone: 'xssFilters'
35 }
36 }
37 }
38 },
39 uglify: {
40 options: {
41 banner: '/**\n'
42 + ' * <%= pkg.name %> - v<%= pkg.version %>\n'
43 + ' * Yahoo! Inc. Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.\n'
44 + ' */\n'
45 },
46 build: {
47 src: 'dist/<%= pkg.name %>.js',
48 dest: 'dist/<%= pkg.name %>.min.js'
49 }
50 },
51 copy: {
52 buildFile: {
53 files: [
54 { dest: 'dist/<%= pkg.name %>.<%= pkg.version %>.min.js', src: 'dist/<%= pkg.name %>.min.js'}
55 ]
56 }
57 },
58 mocha_istanbul: {
59 coverage: {
60 src: 'tests/unit',
61 options: {
62 coverageFolder: 'artifacts/test/coverage',
63 check: {
64 lines: 80,
65 statements: 80
66 },
67 timeout: 10000
68 }
69 }
70 },
71 clean: {
72 all: ['dist', 'artifacts', 'node_modules']
73 }
74 });
75
76 grunt.loadNpmTasks('grunt-mocha-istanbul');
77 grunt.loadNpmTasks('grunt-browserify');
78 grunt.loadNpmTasks('grunt-contrib-uglify');
79 grunt.loadNpmTasks('grunt-contrib-jshint');
80 grunt.loadNpmTasks('grunt-contrib-clean');
81 grunt.loadNpmTasks('grunt-contrib-copy');
82 grunt.loadNpmTasks('grunt-jsdoc');
83
84 grunt.registerTask('test', ['jshint', 'mocha_istanbul']);
85 grunt.registerTask('dist', ['browserify', 'uglify', 'copy:buildFile'])
86 grunt.registerTask('docs', ['jsdoc']);
87 grunt.registerTask('default', ['test', 'dist']);
88
89};