2013-02-20 02:33:40 +08:00
|
|
|
module.exports = function( grunt ) {
|
|
|
|
'use strict';
|
2015-01-27 02:15:37 +08:00
|
|
|
|
|
|
|
function packageVersion() {
|
|
|
|
return require('./package.json').version;
|
|
|
|
}
|
2013-02-20 02:33:40 +08:00
|
|
|
//
|
|
|
|
// Grunt configuration:
|
|
|
|
//
|
|
|
|
// https://github.com/cowboy/grunt/blob/master/docs/getting_started.md
|
|
|
|
//
|
|
|
|
grunt.initConfig({
|
|
|
|
// specifying JSHint options and globals
|
|
|
|
// https://github.com/cowboy/grunt/blob/master/docs/task_lint.md#specifying-jshint-options-and-globals
|
|
|
|
jshint: {
|
|
|
|
options: {
|
|
|
|
boss: true,
|
|
|
|
browser: true,
|
|
|
|
curly: true,
|
|
|
|
eqeqeq: true,
|
|
|
|
eqnull: true,
|
|
|
|
immed: true,
|
|
|
|
latedef: true,
|
|
|
|
newcap: true,
|
|
|
|
noarg: true,
|
|
|
|
sub: true,
|
|
|
|
undef: true,
|
|
|
|
globals: {
|
2015-11-11 01:53:35 +08:00
|
|
|
global: true,
|
2013-02-20 02:33:40 +08:00
|
|
|
jasmine: false,
|
|
|
|
module: false,
|
2014-07-29 09:38:06 +08:00
|
|
|
exports: true,
|
|
|
|
describe: false,
|
|
|
|
it: false,
|
|
|
|
expect: false,
|
|
|
|
beforeEach: false,
|
|
|
|
afterEach: false,
|
2014-08-04 22:46:32 +08:00
|
|
|
spyOn: false,
|
2015-01-27 02:15:37 +08:00
|
|
|
getJasmineRequireObj: false,
|
|
|
|
require: false
|
2013-02-20 02:33:40 +08:00
|
|
|
}
|
|
|
|
},
|
2014-08-04 22:46:32 +08:00
|
|
|
all: ['Gruntfile.js', 'src/**/*.js', 'lib/**/*.js', 'spec/**/*.js']
|
2013-02-20 02:33:40 +08:00
|
|
|
},
|
|
|
|
shell: {
|
|
|
|
ctags: {
|
|
|
|
command: 'ctags -R lib'
|
2015-01-27 02:02:32 +08:00
|
|
|
},
|
|
|
|
release: {
|
|
|
|
command: [
|
|
|
|
'git tag v<%= packageVersion %>',
|
|
|
|
'git push origin master --tags',
|
|
|
|
'npm publish'
|
|
|
|
].join('&&')
|
2013-02-20 02:33:40 +08:00
|
|
|
}
|
2014-08-04 22:46:32 +08:00
|
|
|
},
|
2015-11-11 01:53:35 +08:00
|
|
|
template: {
|
|
|
|
options: {
|
|
|
|
data: function() {
|
|
|
|
return {
|
|
|
|
packageVersion: packageVersion(),
|
|
|
|
files: grunt.file.expand([
|
|
|
|
'src/requireAjax.js',
|
|
|
|
'src/**/*.js',
|
|
|
|
'!src/boot.js'
|
|
|
|
])
|
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
|
|
|
lib: {
|
|
|
|
src: 'src/boot.js',
|
|
|
|
dest: '.tmp/mock-ajax.js'
|
|
|
|
}
|
2015-01-27 02:02:32 +08:00
|
|
|
},
|
2015-11-11 01:53:35 +08:00
|
|
|
includes: {
|
|
|
|
options: {
|
|
|
|
includeRegexp: /\/\/\s*include "(\S+)";/,
|
|
|
|
includePath: '.'
|
|
|
|
},
|
|
|
|
lib: {
|
|
|
|
src: '.tmp/mock-ajax.js',
|
|
|
|
dest: 'lib/mock-ajax.js'
|
|
|
|
}
|
|
|
|
}
|
2015-01-27 02:02:32 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
grunt.registerTask('versionCheck', function() {
|
|
|
|
var pkgVersion = packageVersion(),
|
|
|
|
bower = require('./bower.json'),
|
|
|
|
bowerVersion = bower.version;
|
|
|
|
|
|
|
|
if (pkgVersion !== bowerVersion) {
|
|
|
|
grunt.fail.fatal("package.json and bower.json have different version numbers\n\tpackage.json:\t" + pkgVersion + "\n\tbower.json:\t" + bowerVersion);
|
2013-02-20 02:33:40 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-jshint');
|
2015-11-11 01:53:35 +08:00
|
|
|
grunt.loadNpmTasks('grunt-template');
|
|
|
|
grunt.loadNpmTasks('grunt-includes');
|
2013-02-20 02:33:40 +08:00
|
|
|
grunt.loadNpmTasks('grunt-shell');
|
|
|
|
|
|
|
|
grunt.registerTask('default', ['jshint']);
|
2015-11-11 01:53:35 +08:00
|
|
|
grunt.registerTask('build', ['template:lib', 'includes:lib']);
|
2013-02-20 02:33:40 +08:00
|
|
|
grunt.registerTask('ctags', 'Generate ctags', ['shell:ctags']);
|
2015-01-27 02:02:32 +08:00
|
|
|
grunt.registerTask('release', 'Release ' + packageVersion() + ' to npm', ['versionCheck', 'shell:release']);
|
2013-02-20 02:33:40 +08:00
|
|
|
};
|