@@ -17,11 +17,12 @@ module.exports = function(grunt) {
17
17
18
18
// Project configuration.
19
19
grunt . initConfig ( {
20
+ pluginName : 'smooth-scroll' ,
20
21
bower : './bower.json' ,
21
22
pkg : grunt . file . readJSON ( 'package.json' ) ,
22
23
meta : {
23
24
banner : '/*!<%= "\\n" %>' +
24
- ' * <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
25
+ ' * <%= pkg.title %> - v<%= pkg.version %> - ' +
25
26
'<%= grunt.template.today("yyyy-mm-dd") + "\\n" %>' +
26
27
'<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
27
28
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>' +
@@ -33,8 +34,8 @@ module.exports = function(grunt) {
33
34
} ,
34
35
concat : {
35
36
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'
38
39
} ,
39
40
options : {
40
41
stripBanners : true ,
@@ -44,7 +45,7 @@ module.exports = function(grunt) {
44
45
uglify : {
45
46
all : {
46
47
files : {
47
- 'jquery.<%= pkg.name %>.min.js' : [ '<%= concat.all.dest %>' ]
48
+ 'jquery.<%= pluginName %>.min.js' : [ '<%= concat.all.dest %>' ]
48
49
} ,
49
50
options : {
50
51
preserveComments : 'some'
@@ -62,20 +63,6 @@ module.exports = function(grunt) {
62
63
}
63
64
64
65
} ,
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
- } ,
79
66
jshint : {
80
67
all : [ 'Gruntfile.js' , 'src/**/*.js' ] ,
81
68
options : {
@@ -100,20 +87,20 @@ module.exports = function(grunt) {
100
87
version : {
101
88
patch : {
102
89
src : [
103
- '<%= pkg.name %>.jquery.json' ,
90
+ '<%= pluginName %>.jquery.json' ,
104
91
'package.json' ,
105
- 'src/jquery.<%= pkg.name %>.js' ,
106
- 'jquery.<%= pkg.name %>.js'
92
+ 'src/jquery.<%= pluginName %>.js' ,
93
+ 'jquery.<%= pluginName %>.js'
107
94
] ,
108
95
options : {
109
96
release : 'patch'
110
97
}
111
98
} ,
112
99
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' ]
114
101
} ,
115
102
bannerPatch : {
116
- src : [ 'jquery.<%= pkg.name %>.js' ] ,
103
+ src : [ 'jquery.<%= pluginName %>.js' ] ,
117
104
options : {
118
105
prefix : '- v' ,
119
106
release : 'patch'
@@ -149,25 +136,25 @@ module.exports = function(grunt) {
149
136
grunt . registerTask ( 'deploy' , [ 'setshell:rsync' , 'shell:rsync' ] ) ;
150
137
151
138
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' ) ,
153
141
bowerFile = grunt . config ( 'bower' ) ,
154
142
bower = grunt . file . readJSON ( bowerFile ) ,
155
- pkg = grunt . config ( 'pkg' ) ,
156
- jqConfigFile = pkg . name . replace ( rjQuery , '' ) + '.jquery.json' ,
143
+ jqConfigFile = pkgBasename + '.jquery.json' ,
157
144
jqConfig = grunt . file . readJSON ( jqConfigFile ) ;
158
145
159
- [ 'name' , ' main', 'version' , 'dependencies' , 'keywords' ] . forEach ( function ( el ) {
146
+ [ 'main' , 'version' , 'dependencies' , 'keywords' ] . forEach ( function ( el ) {
160
147
bower [ el ] = pkg [ el ] ;
161
148
jqConfig [ el ] = pkg [ el ] ;
162
149
} ) ;
163
150
164
-
165
151
[ 'author' , 'repository' , 'homepage' , 'docs' , 'bugs' , 'demo' , 'licenses' ] . forEach ( function ( el ) {
166
152
jqConfig [ el ] = pkg [ el ] ;
167
153
} ) ;
168
154
169
155
jqConfig . keywords . shift ( ) ;
170
- jqConfig . name = jqConfig . name . replace ( rjQuery , '' ) ;
156
+ jqConfig . name = pkgBasename ;
157
+ bower . name = 'jquery.' + pkgBasename ;
171
158
172
159
grunt . file . write ( bowerFile , JSON . stringify ( bower , null , 2 ) + '\n' ) ;
173
160
grunt . log . writeln ( 'File "' + bowerFile + '" updated."' ) ;
@@ -178,11 +165,10 @@ module.exports = function(grunt) {
178
165
179
166
grunt . registerTask ( 'docs' , 'Convert readme.md to html and concat with header and footer for index.html' , function ( ) {
180
167
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' ) ) ,
182
169
foot = grunt . file . read ( 'lib/tmpl/footer.tpl' ) ,
183
170
doc = marked ( readme ) ;
184
171
185
-
186
172
grunt . file . write ( 'index.html' , head + doc + foot ) ;
187
173
} ) ;
188
174
0 commit comments