-
Notifications
You must be signed in to change notification settings - Fork 6
/
Gruntfile.js
109 lines (101 loc) · 2.98 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-gh-pages');
grunt.loadNpmTasks('grunt-serve');
var files = {
demo: ['demo/**/*.js'],
lib: ['lib/**/*.js'],
test: ['test/**/*.js'],
build: ['Gruntfile.js']
};
files.all = [].concat(files.demo, files.test, files.lib, files.build);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
options: {
ignores: "**/*.min.js"
},
all: files.all
},
mochaTest: {
test: {
options: {
reporter: 'dot',
clearRequireCache: true
},
src: files.test
}
},
browserify: {
standalone: {
options: {
browserifyOptions: {
standalone: '<%= pkg.name %>'
}
},
dest: 'dest/<%= pkg.name %>.js',
src: files.lib
},
demo: {
dest: 'demo/app.min.js',
src: 'demo/app.js'
}
},
uglify: {
demo: {
files: {
'demo/app.min.js': ['demo/app.min.js']
}
},
dest: {
files: {
'dest/<%= pkg.name %>.min.js': ['dest/<%= pkg.name %>.js']
}
}
},
'gh-pages': {
options: {
base: 'demo',
branch: 'site-production'
},
src: ['**']
},
serve: {
options: {
port: 9000,
serve: {
path: './demo/'
}
}
},
watch: {
test: {
files: files.all,
tasks: [ 'jshint', 'mochaTest' ]
},
build: {
options: {
spawn: false
},
files: files.demo.concat(files.lib),
tasks: [ 'browserify' ]
}
}
});
// run only changed tests when saving test files
var defaultTestSrc = grunt.config('mochaTest.test.src');
grunt.event.on('watch', function(action, filepath) {
grunt.config('mochaTest.test.src', defaultTestSrc);
if (filepath.match('test/')) {
grunt.config('mochaTest.test.src', filepath);
}
});
grunt.registerTask('test', [ 'jshint', 'mochaTest' ]);
grunt.registerTask('package', [ 'browserify', 'uglify' ]);
grunt.registerTask('default', [ 'test', 'package' ]);
grunt.registerTask('publish', [ 'package', 'gh-pages' ]);
};