@@ -5,43 +5,56 @@ var requirejs = require( 'requirejs' ),
55
66module . exports = function ( grunt ) {
77 grunt . registerTask ( "plugins" , function ( ) {
8- var global_config = grunt . config . get ( 'global' ) ,
9- done = this . async ( ) ,
10- output = global_config . plugins . output ;
8+ var globalConfig = pluginConfig = grunt . config . get ( 'global' ) ,
9+ pluginConfig = globalConfig . plugins ,
10+ done = this . async ( ) , filenameToPlugin ;
11+
12+ filenameToPlugin = function ( filename ) {
13+ var pathless = filename . replace ( / j s \/ / , "" ) ,
14+ newFilename , template ;
15+
16+ // if the file is one of the old convention top level
17+ // just strip the js dir, otherwise use the directory
18+ // names for namespaces
19+ if ( / j q u e r y \. m o b i l e / . test ( filename ) ) {
20+ newFilename = pathless ;
21+ } else {
22+ newFilename = pathless . split ( "/" ) . join ( "." ) ;
23+ }
24+
25+ return "mobile." + newFilename
26+ . replace ( "jquery.mobile." , "" )
27+ . replace ( ".js" , ".jquery.json" ) ;
28+ } ;
1129
1230 requirejs . tools . useLib ( function ( require ) {
1331 require ( [ 'parse' ] , function ( parse ) {
1432 // grab all the files that still use the original convention
1533 var files = [ ] , distFiles ;
1634
17- global_config . plugins . globs . forEach ( function ( globstr ) {
35+ pluginConfig . globs . forEach ( function ( globstr ) {
1836 // glob glob glob ... namespace fail
1937 files = files . concat ( glob . glob ( globstr ) ) ;
2038 } ) ;
2139
2240 files . forEach ( function ( filename , i ) {
41+ if ( pluginConfig . exclude . test ( filename ) ) {
42+ return ;
43+ }
44+
2345 var data = fs . readFileSync ( filename , 'utf8' ) ,
2446 tree = parse . findDependencies ( filename , data ) ,
25- pathless = filename . replace ( / j s \/ / , "" ) ,
26- newFilename , manifest , template ;
27-
28- // TODO splitting this out using the above globs would be faster/better
29- if ( / j q u e r y \. m o b i l e / . test ( filename ) ) {
30- newFilename = pathless ;
31- grunt . file . copy ( filename , output + newFilename ) ;
32- } else {
33- newFilename = "jquery.mobile." + pathless . split ( "/" ) . join ( "." ) ;
34- grunt . file . copy ( filename , output + newFilename ) ;
35- }
47+ manifest , template ;
48+
49+ template = grunt . file . read ( pluginConfig . template ) ;
50+
51+ manifest = filenameToPlugin ( filename ) ;
3652
37- manifest = "dist." + newFilename . replace ( ".js" , ".json" ) ;
38- template = grunt . file . read ( global_config . plugins . template ) ;
3953 grunt . file . write ( manifest , grunt . template . process ( template , {
40- name : "foo" ,
41- title : "bar" ,
42- desc : "baz" ,
43- version : global_config . ver . official ,
44- dependencies : ""
54+ name : filename . replace ( ".json" , "" ) ,
55+ title : "TODO" ,
56+ desc : "TODO" ,
57+ version : globalConfig . ver . official
4558 } ) ) ;
4659 } ) ;
4760 } ) ;
0 commit comments