2012-11-25 22:59:31 +04:00
|
|
|
/*global module:false*/
|
|
|
|
module.exports = function(grunt) {
|
|
|
|
|
2014-01-19 20:04:27 +04:00
|
|
|
var meta = {
|
|
|
|
banner: '/*\n <%= pkg.title || pkg.name %> <%= pkg.version %>' +
|
|
|
|
'<%= pkg.homepage ? " <" + pkg.homepage + ">" : "" %>' + '\n' +
|
|
|
|
' Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>' +
|
|
|
|
'\n\n Released under <%= _.pluck(pkg.licenses, "type").join(", ") %> License\n*/\n',
|
|
|
|
pre: '\n(function(window, document, undefined){\n\n',
|
|
|
|
post: '\n})(window,document);'
|
|
|
|
};
|
2013-03-22 22:57:38 +04:00
|
|
|
|
2014-01-19 20:04:27 +04:00
|
|
|
// Project configuration.
|
|
|
|
grunt.initConfig({
|
2013-03-22 22:57:38 +04:00
|
|
|
|
2014-01-19 20:04:27 +04:00
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
2013-03-22 22:57:38 +04:00
|
|
|
|
2014-01-19 20:04:27 +04:00
|
|
|
qunit: {
|
|
|
|
files: ['tests/qunit/index.html']
|
|
|
|
},
|
|
|
|
concat: {
|
|
|
|
dist: {
|
|
|
|
src: [
|
2014-03-15 15:22:55 +04:00
|
|
|
'src/promise.js', 'src/fallback.js', 'src/**/*.js'
|
2014-01-19 20:04:27 +04:00
|
|
|
],
|
|
|
|
dest: 'build/<%= pkg.name %>.js'
|
|
|
|
},
|
|
|
|
options:{
|
|
|
|
banner: meta.banner + meta.pre,
|
|
|
|
footer: meta.post
|
|
|
|
}
|
|
|
|
},
|
|
|
|
connect: {
|
|
|
|
server: {
|
|
|
|
options: {
|
|
|
|
port: 8080,
|
|
|
|
base: './',
|
|
|
|
keepalive: true
|
|
|
|
}
|
2014-05-18 18:39:24 +04:00
|
|
|
},
|
2014-05-18 18:40:01 +04:00
|
|
|
cors: {
|
|
|
|
options: {
|
|
|
|
port: 8081,
|
|
|
|
base: './',
|
|
|
|
keepalive: false,
|
|
|
|
middleware: function(connect, options, middlwares) {
|
|
|
|
return [
|
|
|
|
function(req, res, next) {
|
|
|
|
if (req.url !== '/tests/assets/image2.jpg') {
|
|
|
|
next();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
|
|
res.end(require("fs").readFileSync('tests/assets/image2.jpg'));
|
|
|
|
},
|
|
|
|
connect.static(options.base[0])
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2014-05-18 18:39:24 +04:00
|
|
|
ci: {
|
|
|
|
options: {
|
|
|
|
port: 8080,
|
|
|
|
base: './',
|
|
|
|
keepalive: false
|
|
|
|
}
|
2014-01-19 20:04:27 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
uglify: {
|
|
|
|
dist: {
|
|
|
|
src: ['<%= concat.dist.dest %>'],
|
|
|
|
dest: 'build/<%= pkg.name %>.min.js'
|
|
|
|
},
|
|
|
|
options: {
|
|
|
|
banner: meta.banner
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
files: 'src/**/*',
|
2014-01-26 20:10:04 +04:00
|
|
|
tasks: ['jshint', 'build']
|
2014-01-19 20:04:27 +04:00
|
|
|
},
|
|
|
|
jshint: {
|
2014-01-26 20:10:04 +04:00
|
|
|
all: ['src/**/*.js', '!src/promise.js'],
|
2014-01-19 20:04:27 +04:00
|
|
|
options: grunt.file.readJSON('./.jshintrc')
|
|
|
|
}
|
|
|
|
});
|
2012-11-25 22:59:31 +04:00
|
|
|
|
2014-01-19 20:04:27 +04:00
|
|
|
grunt.registerTask('webdriver', 'Browser render tests', function(arg1) {
|
|
|
|
var selenium = require("./tests/selenium.js");
|
|
|
|
var done = this.async();
|
2012-12-29 17:02:05 +04:00
|
|
|
|
2014-01-19 20:04:27 +04:00
|
|
|
if (arguments.length) {
|
|
|
|
selenium[arg1].apply(null, arguments);
|
|
|
|
} else {
|
2014-05-18 18:39:24 +04:00
|
|
|
selenium.tests().onValue(done);
|
2014-01-19 20:04:27 +04:00
|
|
|
}
|
|
|
|
});
|
2012-12-29 17:02:05 +04:00
|
|
|
|
2014-01-19 20:04:27 +04:00
|
|
|
// Load tasks
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-concat');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-uglify');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-jshint');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-qunit');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-connect');
|
2013-03-22 06:40:09 +04:00
|
|
|
|
2014-01-19 20:04:27 +04:00
|
|
|
// Default task.
|
2014-05-18 18:40:01 +04:00
|
|
|
grunt.registerTask('server', ['connect:cors', 'connect']);
|
2014-01-19 20:04:27 +04:00
|
|
|
grunt.registerTask('build', ['concat', 'uglify']);
|
2014-01-26 20:10:04 +04:00
|
|
|
grunt.registerTask('default', ['jshint', 'concat', 'qunit', 'uglify']);
|
2014-05-18 18:40:01 +04:00
|
|
|
grunt.registerTask('travis', ['jshint', 'concat','qunit', 'uglify', 'connect:ci', 'connect:cors', 'webdriver']);
|
2012-11-25 22:59:31 +04:00
|
|
|
|
|
|
|
};
|