-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
110 lines (106 loc) · 2.97 KB
/
Gruntfile.js
File metadata and controls
110 lines (106 loc) · 2.97 KB
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
110
var os = require('os')
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
bower: {
install: {
options: {
copy: false
}
}
},
uglify: {
build: {
src: 'lib/wss.bundle.js',
dest: 'lib/wss.bundle.min.js'
}
},
browserify: {
dist: {
files: {
'lib/wss.bundle.js': ['src/wss.coffee'],
},
options: {
transform: ['coffeeify'],
browserifyOptions: {
extensions: ['.coffee']
},
bundleOptions: {
standalone: 'ufo'
}
}
}
},
mochacli: {
options: {
compilers: ['coffee:coffee-script/register'],
files: ['test/*.coffee']
},
test: {
options: {
reporter: 'spec'
}
},
coverage: {
options: {
reporter: 'html-cov',
require: ['./lib/coffee-coverage-register-handlers/register-handlers.js'],
save: '/tmp/wssjs-coverage.html'
}
}
},
karma: {
unit: {
configFile: 'integration-test/karma.conf.js'
}
},
shell: {
copyStack: {
command: function() {
return 'cp lib/wss.bundle.js integration-test/chrome-app/';
}
},
runchrome: {
command: function() {
var chrome = null;
var currentOS = os.type();
if(currentOS=='Darwin')
chrome = '/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome';
return chrome + ' --load-and-launch-app=integration-test/chrome-app --user-data-dir=/tmp/testufo';
}
},
coverageresult: {
command: function() {
var command = null;
var currentOS = os.type();
if(currentOS=='Darwin')
command = 'open'
return command + ' /tmp/wssjs-coverage.html'
}
}
},
watch: {
test: {
files: ['test/*.coffee', 'src/*.coffee'],
tasks: 'mochacli:test'
}
},
clean: ['lib/', 'node_modules']
});
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-mocha-cli');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-bower-task');
grunt.registerTask('installDeps', ['bower:install']);
grunt.registerTask('unit-test', ['mochacli:test']);
grunt.registerTask('compile', ['installDeps', 'browserify', 'uglify']);
grunt.registerTask('integration-test', ['shell:copyStack', 'karma']);
grunt.registerTask('run-chrome', ['unit-test', 'compile', 'integration-test', 'shell:runchrome']);
grunt.registerTask('develop', ['installDeps', 'watch:test']);
grunt.registerTask('coverage', ['mochacli:coverage', 'shell:coverageresult']);
grunt.registerTask('default', ['compile']);
};