2
2
3
3
var _ = require ( "lodash" ) ,
4
4
5
- fmd = require ( "fmd" ) ;
5
+ fmd = require ( "fmd" ) ;
6
6
7
7
module . exports = function ( grunt ) {
8
8
@@ -14,78 +14,76 @@ module.exports = function (grunt) {
14
14
modules = { } ,
15
15
16
16
config = {
17
- target : this . target + '/' ,
18
- factories : [ "commonjs" , "amd" , "global" ] ,
19
- trim_whitespace : true ,
20
- new_line : "unix" ,
21
- indent : "\t"
22
- } ;
17
+ target : this . target + '/' ,
18
+ factories : [ "commonjs" , "amd" , "global" ] ,
19
+ trim_whitespace : true ,
20
+ new_line : "unix" ,
21
+ indent : "\t"
22
+ } ;
23
23
24
24
// Prepare Factory-Module-Definition settings
25
- _ . each ( options , function ( conf , name ) {
25
+ _ . each ( options , ( conf , name ) => {
26
26
var sources = [ ] ,
27
27
28
- opts = {
29
- depends : { }
30
- } ,
28
+ opts = {
29
+ depends : { }
30
+ } ,
31
31
32
- deps = [ ] ;
32
+ deps = [ ] ;
33
33
34
- if ( conf . exports ) {
35
- opts . exports = conf . exports ;
36
- }
34
+ if ( conf . exports ) {
35
+ opts . exports = conf . exports ;
36
+ }
37
37
38
- if ( conf . global ) {
39
- opts . global = conf . global ;
40
- }
38
+ if ( conf . global ) {
39
+ opts . global = conf . global ;
40
+ }
41
41
42
42
// Find and add self as source
43
- _ . each ( this . filesSrc , function ( source ) {
44
- if ( grunt . file . exists ( source + name + ".js" ) ) {
45
- sources . push ( source + name + ".js" ) ;
46
- }
47
- } , this ) ;
43
+ _ . each ( this . filesSrc , ( source ) => {
44
+ if ( grunt . file . exists ( source + name + ".js" ) ) {
45
+ sources . push ( source + name + ".js" ) ;
46
+ }
47
+ } ) ;
48
48
49
49
if ( conf . pack ) {
50
- // Collect all components
51
- deps = _ . chain ( conf . components )
52
- . map ( function ( depName ) {
53
- return options [ depName ] . components ;
54
- } )
55
- . flatten ( )
56
- . uniq ( )
57
- . without ( name )
58
- . sort ( function ( a , b ) {
59
- return options [ a ] . components . indexOf ( b ) === - 1 ? - 1 : 1 ;
60
- } )
61
- . value ( ) ;
50
+ // Collect all components
51
+ deps = _ . chain ( conf . components )
52
+ . map ( depName => options [ depName ] . components )
53
+ . flatten ( )
54
+ . uniq ( )
55
+ . without ( name )
56
+ . sort ( ( a , b ) => {
57
+ return options [ a ] . components . indexOf ( b ) === - 1 ? - 1 : 1 ;
58
+ } )
59
+ . value ( ) ;
62
60
63
61
// Add components as source files -> results a single file
64
- _ . each ( this . filesSrc , function ( source ) {
65
- _ . each ( deps , function ( depName ) {
66
- if ( grunt . file . exists ( source + depName + ".js" ) ) {
67
- sources . push ( source + depName + ".js" ) ;
68
- }
69
- } ) ;
70
- } , this ) ;
62
+ _ . each ( this . filesSrc , ( source ) => {
63
+ _ . each ( deps , ( depName ) => {
64
+ if ( grunt . file . exists ( source + depName + ".js" ) ) {
65
+ sources . push ( source + depName + ".js" ) ;
66
+ }
67
+ } ) ;
68
+ } ) ;
71
69
} else {
72
- // Read components and add them as dependecies
73
- _ . each ( _ . without ( conf . components , name ) , function ( value , i ) {
74
- opts . depends [ './' + value ] = value === "core" ? "CryptoJS" : null ;
75
- } ) ;
76
- }
70
+ // Read components and add them as dependecies
71
+ _ . each ( _ . without ( conf . components , name ) , ( value , i ) => {
72
+ opts . depends [ './' + value ] = value === "core" ? "CryptoJS" : null ;
73
+ } ) ;
74
+ }
77
75
78
- // Remove duplicates
79
- sources = _ . uniq ( sources ) ;
76
+ // Remove duplicates
77
+ sources = _ . uniq ( sources ) ;
80
78
81
79
// Add module settings to fmd definition
82
- modules [ name ] = [ sources , opts ] ;
83
- } , this ) ;
80
+ modules [ name ] = [ sources , opts ] ;
81
+ } ) ;
84
82
85
- // Build packege modules
86
- fmd ( config )
87
- . define ( modules )
88
- . build ( function ( createdFiles ) {
83
+ // Build packege modules
84
+ fmd ( config )
85
+ . define ( modules )
86
+ . build ( ( ) => {
89
87
90
88
done ( ) ;
91
89
} ) ;
0 commit comments