2015-05-11 01:19:55 +08:00
|
|
|
var sauceConfig = require('./build/saucelabs-config')
|
2014-09-26 13:26:23 +08:00
|
|
|
|
2014-07-09 01:45:53 +08:00
|
|
|
module.exports = function (grunt) {
|
|
|
|
|
2014-07-09 06:14:04 +08:00
|
|
|
grunt.initConfig({
|
|
|
|
|
2014-09-30 00:36:31 +08:00
|
|
|
version: grunt.file.readJSON('package.json').version,
|
2014-09-02 00:37:22 +08:00
|
|
|
|
2014-07-09 06:14:04 +08:00
|
|
|
jshint: {
|
|
|
|
options: {
|
|
|
|
reporter: require('jshint-stylish'),
|
|
|
|
jshintrc: true
|
|
|
|
},
|
|
|
|
build: {
|
|
|
|
src: ['gruntfile.js', 'tasks/*.js']
|
|
|
|
},
|
|
|
|
src: {
|
|
|
|
src: 'src/**/*.js'
|
|
|
|
},
|
|
|
|
test: {
|
2014-09-23 19:46:53 +08:00
|
|
|
src: ['test/unit/specs/**/*.js', 'test/e2e/*.js']
|
2014-07-09 06:14:04 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
karma: {
|
|
|
|
options: {
|
|
|
|
frameworks: ['jasmine', 'commonjs'],
|
|
|
|
files: [
|
2015-02-25 22:39:41 +08:00
|
|
|
'test/unit/lib/jquery.js',
|
2014-07-09 06:14:04 +08:00
|
|
|
'src/**/*.js',
|
2014-08-19 06:03:01 +08:00
|
|
|
'test/unit/specs/**/*.js'
|
2014-07-09 06:14:04 +08:00
|
|
|
],
|
|
|
|
preprocessors: {
|
|
|
|
'src/**/*.js': ['commonjs'],
|
2014-08-19 06:03:01 +08:00
|
|
|
'test/unit/specs/**/*.js': ['commonjs']
|
2014-07-09 06:14:04 +08:00
|
|
|
},
|
|
|
|
singleRun: true
|
|
|
|
},
|
|
|
|
browsers: {
|
|
|
|
options: {
|
2014-10-16 06:52:40 +08:00
|
|
|
browsers: ['Chrome', 'Firefox', 'Safari'],
|
2014-07-10 07:08:01 +08:00
|
|
|
reporters: ['progress']
|
|
|
|
}
|
|
|
|
},
|
2014-09-26 13:26:23 +08:00
|
|
|
coverage: {
|
2014-07-10 07:08:01 +08:00
|
|
|
options: {
|
|
|
|
browsers: ['PhantomJS'],
|
2014-08-06 02:29:53 +08:00
|
|
|
reporters: ['progress', 'coverage'],
|
|
|
|
preprocessors: {
|
|
|
|
'src/**/*.js': ['commonjs', 'coverage'],
|
2014-08-19 06:03:01 +08:00
|
|
|
'test/unit/specs/**/*.js': ['commonjs']
|
2014-08-06 02:29:53 +08:00
|
|
|
},
|
|
|
|
coverageReporter: {
|
|
|
|
reporters: [
|
|
|
|
{ type: 'lcov' },
|
|
|
|
{ type: 'text-summary' }
|
|
|
|
]
|
|
|
|
}
|
2014-07-09 06:14:04 +08:00
|
|
|
}
|
2014-09-26 13:26:23 +08:00
|
|
|
},
|
|
|
|
sauce1: {
|
|
|
|
options: sauceConfig.batch1
|
|
|
|
},
|
|
|
|
sauce2: {
|
|
|
|
options: sauceConfig.batch2
|
|
|
|
},
|
|
|
|
sauce3: {
|
|
|
|
options: sauceConfig.batch3
|
2014-07-09 06:14:04 +08:00
|
|
|
}
|
2014-09-27 01:33:03 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
coveralls: {
|
|
|
|
options: {
|
|
|
|
coverage_dir: 'coverage/',
|
|
|
|
force: true
|
|
|
|
}
|
2014-07-09 06:14:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
2014-07-09 06:35:39 +08:00
|
|
|
// load npm tasks
|
2014-07-09 06:14:04 +08:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-jshint')
|
|
|
|
grunt.loadNpmTasks('grunt-karma')
|
2014-09-27 01:33:03 +08:00
|
|
|
grunt.loadNpmTasks('grunt-karma-coveralls')
|
2014-07-09 01:45:53 +08:00
|
|
|
|
2014-07-09 06:35:39 +08:00
|
|
|
// load custom tasks
|
2015-05-11 01:26:30 +08:00
|
|
|
require('./build/grunt-tasks/build')(grunt)
|
|
|
|
require('./build/grunt-tasks/casper')(grunt)
|
|
|
|
require('./build/grunt-tasks/release')(grunt)
|
2014-07-09 06:35:39 +08:00
|
|
|
|
2015-05-11 01:26:30 +08:00
|
|
|
// register composite tasks
|
2014-07-09 06:14:04 +08:00
|
|
|
grunt.registerTask('unit', ['karma:browsers'])
|
2014-09-26 13:26:23 +08:00
|
|
|
grunt.registerTask('cover', ['karma:coverage'])
|
2014-09-23 19:46:53 +08:00
|
|
|
grunt.registerTask('test', ['unit', 'cover', 'casper'])
|
2014-09-26 13:26:23 +08:00
|
|
|
grunt.registerTask('sauce', ['karma:sauce1', 'karma:sauce2', 'karma:sauce3'])
|
2014-10-28 03:31:03 +08:00
|
|
|
grunt.registerTask('ci', ['jshint', 'cover', 'coveralls', 'build', 'casper', 'sauce'])
|
2014-10-01 13:53:12 +08:00
|
|
|
grunt.registerTask('default', ['jshint', 'build', 'test'])
|
2014-07-09 01:45:53 +08:00
|
|
|
|
|
|
|
}
|