@@ -17,11 +17,12 @@ module.exports = function(grunt) {
1717
1818 // Project configuration.
1919 grunt . initConfig ( {
20+ pluginName : 'smooth-scroll' ,
2021 bower : './bower.json' ,
2122 pkg : grunt . file . readJSON ( 'package.json' ) ,
2223 meta : {
2324 banner : '/*!<%= "\\n" %>' +
24- ' * <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
25+ ' * <%= pkg.title %> - v<%= pkg.version %> - ' +
2526 '<%= grunt.template.today("yyyy-mm-dd") + "\\n" %>' +
2627 '<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
2728 ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>' +
@@ -33,8 +34,8 @@ module.exports = function(grunt) {
3334 } ,
3435 concat : {
3536 all : {
36- src : [ 'src/jquery.<%= pkg.name %>.js' ] ,
37- dest : 'jquery.<%= pkg.name %>.js'
37+ src : [ 'src/jquery.<%= pluginName %>.js' ] ,
38+ dest : 'jquery.<%= pluginName %>.js'
3839 } ,
3940 options : {
4041 stripBanners : true ,
@@ -44,7 +45,7 @@ module.exports = function(grunt) {
4445 uglify : {
4546 all : {
4647 files : {
47- 'jquery.<%= pkg.name %>.min.js' : [ '<%= concat.all.dest %>' ]
48+ 'jquery.<%= pluginName %>.min.js' : [ '<%= concat.all.dest %>' ]
4849 } ,
4950 options : {
5051 preserveComments : 'some'
@@ -62,20 +63,6 @@ module.exports = function(grunt) {
6263 }
6364
6465 } ,
65- shell : {
66- rsync : {
67- // command is set by setshell:rsync.
68- options : {
69- stdout : true
70- }
71- }
72- } ,
73- setshell : {
74- rsync : {
75- file : 'gitignore/settings.json' ,
76- cmdAppend : '<%= pkg.name %>/'
77- }
78- } ,
7966 jshint : {
8067 all : [ 'Gruntfile.js' , 'src/**/*.js' ] ,
8168 options : {
@@ -100,20 +87,20 @@ module.exports = function(grunt) {
10087 version : {
10188 patch : {
10289 src : [
103- '<%= pkg.name %>.jquery.json' ,
90+ '<%= pluginName %>.jquery.json' ,
10491 'package.json' ,
105- 'src/jquery.<%= pkg.name %>.js' ,
106- 'jquery.<%= pkg.name %>.js'
92+ 'src/jquery.<%= pluginName %>.js' ,
93+ 'jquery.<%= pluginName %>.js'
10794 ] ,
10895 options : {
10996 release : 'patch'
11097 }
11198 } ,
11299 same : {
113- src : [ 'package.json' , 'src/jquery.<%= pkg.name %>.js' , 'jquery.<%= pkg.name %>.js' ]
100+ src : [ 'package.json' , 'src/jquery.<%= pluginName %>.js' , 'jquery.<%= pluginName %>.js' ]
114101 } ,
115102 bannerPatch : {
116- src : [ 'jquery.<%= pkg.name %>.js' ] ,
103+ src : [ 'jquery.<%= pluginName %>.js' ] ,
117104 options : {
118105 prefix : '- v' ,
119106 release : 'patch'
@@ -149,25 +136,25 @@ module.exports = function(grunt) {
149136 grunt . registerTask ( 'deploy' , [ 'setshell:rsync' , 'shell:rsync' ] ) ;
150137
151138 grunt . registerTask ( 'configs' , 'Update json configs based on package.json' , function ( ) {
152- var rjQuery = / ^ j q u e r y \. / ,
139+ var pkg = grunt . config ( 'pkg' ) ,
140+ pkgBasename = grunt . config ( 'pluginName' ) ,
153141 bowerFile = grunt . config ( 'bower' ) ,
154142 bower = grunt . file . readJSON ( bowerFile ) ,
155- pkg = grunt . config ( 'pkg' ) ,
156- jqConfigFile = pkg . name . replace ( rjQuery , '' ) + '.jquery.json' ,
143+ jqConfigFile = pkgBasename + '.jquery.json' ,
157144 jqConfig = grunt . file . readJSON ( jqConfigFile ) ;
158145
159- [ 'name' , ' main', 'version' , 'dependencies' , 'keywords' ] . forEach ( function ( el ) {
146+ [ 'main' , 'version' , 'dependencies' , 'keywords' ] . forEach ( function ( el ) {
160147 bower [ el ] = pkg [ el ] ;
161148 jqConfig [ el ] = pkg [ el ] ;
162149 } ) ;
163150
164-
165151 [ 'author' , 'repository' , 'homepage' , 'docs' , 'bugs' , 'demo' , 'licenses' ] . forEach ( function ( el ) {
166152 jqConfig [ el ] = pkg [ el ] ;
167153 } ) ;
168154
169155 jqConfig . keywords . shift ( ) ;
170- jqConfig . name = jqConfig . name . replace ( rjQuery , '' ) ;
156+ jqConfig . name = pkgBasename ;
157+ bower . name = 'jquery.' + pkgBasename ;
171158
172159 grunt . file . write ( bowerFile , JSON . stringify ( bower , null , 2 ) + '\n' ) ;
173160 grunt . log . writeln ( 'File "' + bowerFile + '" updated."' ) ;
@@ -178,11 +165,10 @@ module.exports = function(grunt) {
178165
179166 grunt . registerTask ( 'docs' , 'Convert readme.md to html and concat with header and footer for index.html' , function ( ) {
180167 var readme = grunt . file . read ( 'readme.md' ) ,
181- head = grunt . template . process ( grunt . file . read ( 'lib/tmpl/header.tpl' ) ) ,
168+ head = grunt . template . process ( grunt . file . read ( 'lib/tmpl/header.tpl' ) ) ,
182169 foot = grunt . file . read ( 'lib/tmpl/footer.tpl' ) ,
183170 doc = marked ( readme ) ;
184171
185-
186172 grunt . file . write ( 'index.html' , head + doc + foot ) ;
187173 } ) ;
188174
0 commit comments