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: {
|
|
|
|
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
|
|
|
},
|
|
|
|
concat: {
|
|
|
|
mockAjax: {
|
|
|
|
src: [
|
|
|
|
'src/requireAjax.js',
|
|
|
|
'src/**/*.js',
|
|
|
|
'!src/boot.js',
|
|
|
|
'src/boot.js'
|
|
|
|
],
|
|
|
|
dest: 'lib/mock-ajax.js'
|
|
|
|
}
|
2015-01-27 02:02:32 +08:00
|
|
|
},
|
|
|
|
packageVersion: packageVersion()
|
|
|
|
});
|
|
|
|
|
|
|
|
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');
|
2014-08-04 22:46:32 +08:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-concat');
|
2013-02-20 02:33:40 +08:00
|
|
|
grunt.loadNpmTasks('grunt-shell');
|
|
|
|
|
|
|
|
grunt.registerTask('default', ['jshint']);
|
|
|
|
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
|
|
|
};
|