Skip to content

Commit 767ab54

Browse files
committed
Make plugin UMD-compliant (works with AMD, CommonJS, or neither). Clean up Gruntfile.
1 parent bbca1e9 commit 767ab54

File tree

9 files changed

+243
-240
lines changed

9 files changed

+243
-240
lines changed

Gruntfile.js

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
module.exports = function(grunt) {
44

55
var marked = require('marked');
6-
// var hl = require('highlight').Highlight;
76
var hl = require('node-syntaxhighlighter');
7+
88
marked.setOptions({
99
highlight: function(code, lang) {
1010
lang = lang || 'javascript';
@@ -39,7 +39,17 @@ module.exports = function(grunt) {
3939
},
4040
options: {
4141
stripBanners: true,
42-
banner: '<%= meta.banner %>'
42+
banner: '<%= meta.banner %>',
43+
process: function(src) {
44+
var umdHead = grunt.file.read('lib/tmpl/umdhead.tpl'),
45+
umdFoot = grunt.file.read('lib/tmpl/umdfoot.tpl');
46+
47+
src = src
48+
.replace('(function($) {', umdHead)
49+
.replace('})(jQuery);', umdFoot);
50+
51+
return src;
52+
}
4353
}
4454
},
4555
uglify: {
@@ -110,32 +120,6 @@ module.exports = function(grunt) {
110120
}
111121
});
112122

113-
grunt.registerMultiTask( 'setshell', 'Set grunt shell commands', function() {
114-
var settings, cmd,
115-
tgt = this.target,
116-
cmdLabel = 'shell.' + tgt + '.command',
117-
file = this.data.file,
118-
append = this.data.cmdAppend || '';
119-
120-
if ( !grunt.file.exists(file) ) {
121-
grunt.warn('File does not exist: ' + file);
122-
}
123-
124-
settings = grunt.file.readJSON(file);
125-
if (!settings[tgt]) {
126-
grunt.warn('No ' + tgt + ' property found in ' + file);
127-
}
128-
129-
cmd = settings[tgt] + append;
130-
grunt.config(cmdLabel, cmd);
131-
grunt.log.writeln( ('Setting ' + cmdLabel + ' to:').cyan );
132-
133-
grunt.log.writeln(cmd);
134-
135-
});
136-
137-
grunt.registerTask( 'deploy', ['setshell:rsync', 'shell:rsync']);
138-
139123
grunt.registerTask( 'configs', 'Update json configs based on package.json', function() {
140124
var pkg = grunt.file.readJSON('package.json'),
141125
pkgBasename = grunt.config('pluginName'),
@@ -182,5 +166,4 @@ module.exports = function(grunt) {
182166
grunt.loadNpmTasks('grunt-contrib-concat');
183167
grunt.loadNpmTasks('grunt-contrib-watch');
184168
grunt.loadNpmTasks('grunt-version');
185-
grunt.loadNpmTasks('grunt-shell');
186169
};

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jquery.smooth-scroll",
3-
"version": "1.5.2",
3+
"version": "1.5.3",
44
"dependencies": {
55
"jquery": ">=1.3"
66
},

0 commit comments

Comments
 (0)