You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
1.9 KiB

10 years ago
module.exports = function (grunt) {
'use strict';
11 years ago
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
version: {
10 years ago
js: {
src: ['<%= pkg.exportName %>.js', '*.json']
},
cdn: {
options: {
prefix: '(cdnjs\\.cloudflare\\.com\\/ajax\\/libs\\/Sortable|cdn\\.jsdelivr\\.net\\/sortable)\\/',
replace: '[0-9\\.]+'
},
src: ['README.md']
}
11 years ago
},
10 years ago
jshint: {
all: ['*.js', '!*.min.js'],
options: {
jshintrc: true
10 years ago
}
},
11 years ago
uglify: {
options: {
banner: '/*! <%= pkg.exportName %> <%= pkg.version %> - <%= pkg.license %> | <%= pkg.repository.url %> */\n'
},
dist: {
files: {
10 years ago
'<%= pkg.exportName %>.min.js': ['<%= pkg.exportName %>.js']
11 years ago
}
},
jquery: {
files: {
'jquery.fn.sortable.min.js': 'jquery.fn.sortable.js'
}
11 years ago
}
},
exec: {
'meteor-test': {
command: 'meteor/runtests.sh'
},
'meteor-publish': {
command: 'meteor/publish.sh'
}
},
jquery: {}
});
grunt.registerTask('jquery', function (arg) {
var fs = require('fs'),
filename = 'jquery.fn.sortable.js';
grunt.log.oklns(filename);
fs.writeFileSync(
filename,
(fs.readFileSync('jquery.binding.js') + '')
.replace('/* CODE */',
(fs.readFileSync('Sortable.js') + '')
.replace(/^[\s\S]*?function[\s\S]*?(var[\s\S]+)\/\/\s+Export[\s\S]+/, '$1')
)
);
if (arg === 'min') {
grunt.task.run('uglify:jquery');
}
11 years ago
});
grunt.loadNpmTasks('grunt-version');
10 years ago
grunt.loadNpmTasks('grunt-contrib-jshint');
11 years ago
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-exec');
11 years ago
// Meteor tasks
grunt.registerTask('meteor-test', 'exec:meteor-test');
grunt.registerTask('meteor-publish', 'exec:meteor-publish');
grunt.registerTask('meteor', ['meteor-test', 'meteor-publish']);
11 years ago
10 years ago
grunt.registerTask('tests', ['jshint']);
grunt.registerTask('default', ['tests', 'version', 'uglify:dist']);
11 years ago
};