@@ -3,6 +3,7 @@ module.exports = function(grunt) {
3
3
4
4
var fs = require ( "fs" ) ;
5
5
var vm = require ( "vm" ) ;
6
+ var rimraf = require ( 'rimraf' ) ;
6
7
7
8
var _includeInThisScope = function ( path ) {
8
9
var code = fs . readFileSync ( path ) ;
@@ -11,20 +12,19 @@ module.exports = function(grunt) {
11
12
_includeInThisScope ( "grunt/plugin_list.js" ) ;
12
13
_includeInThisScope ( "grunt/helpers.js" ) ;
13
14
15
+
14
16
var generateListFile = function ( source ) {
15
17
var sourceObj = ( source === "module" ) ? modules : themes ;
16
-
17
18
var found = [ ] ;
18
19
for ( var i = 0 ; i < sourceObj . length ; i ++ ) {
19
20
var folder = source + "-" + sourceObj [ i ] ;
20
21
var packageFile = "repos/" + folder + "/package.json" ;
21
22
if ( ! fs . existsSync ( packageFile ) ) {
22
23
continue ;
23
24
}
24
-
25
25
var json = grunt . file . readJSON ( packageFile ) ;
26
26
27
- // copy the icons out of the module/theme
27
+ // copy the icons out of the module/theme and into the docs section
28
28
if ( source === "module" ) {
29
29
copyIcons ( folder , json . icons ) ;
30
30
} else {
@@ -33,57 +33,50 @@ module.exports = function(grunt) {
33
33
34
34
// append the folder name. This is used to construct links to the icons
35
35
json . folder = folder ;
36
-
37
36
found . push ( json ) ;
38
37
}
39
38
40
39
grunt . file . write ( "_data/" + source + "_list.json" , JSON . stringify ( found ) ) ;
41
40
} ;
42
41
43
-
44
- var iconFile , targetFolder ;
45
42
var copyIcons = function ( folder , icons ) {
46
-
47
- // remove the old folder
48
- config . clean . folder = [ "./assets/generated/" + folder ] ;
49
- grunt . task . run ( "clean:folder" )
43
+ // wipe out of the old folder and recreate it
44
+ var path = "assets/generated/" + folder ;
45
+ rimraf . sync ( path ) ;
46
+ fs . mkdirSync ( path ) ;
50
47
51
48
// now copy over the icons
52
49
for ( var icon in icons ) {
53
- iconFile = "./repos/" + folder + "/" + icons [ icon ] ;
54
- targetFolder = "assets/generated/" + folder + "/" ;
55
-
56
- // create the folder
57
- grunt . task . run ( "shell:copyIcon" ) ;
50
+ var sourceFile = "./repos/" + folder + "/assets/images/" + icons [ icon ] ;
51
+ var targetLocation = "assets/generated/" + folder + "/" + icons [ icon ] ;
52
+ copyFileSync ( sourceFile , targetLocation ) ;
58
53
}
59
54
} ;
60
55
61
- var getCopyIconCommand = function ( ) {
62
- var commands = [ ] ;
63
- commands . push ( "sudo mkdir " + targetFolder ) ;
64
- commands . push ( "sudo chmod 777 " + targetFolder ) ;
65
- commands . push ( "sudo cp " + iconFile + " " + targetFolder ) ;
66
-
67
- console . log ( "_______________________________" ) ;
68
- console . log ( commands ) ;
69
- console . log ( "_______________________________" ) ;
70
-
71
- return commands . join ( '&&' ) ;
56
+ var copyFileSync = function ( srcFile , destFile ) {
57
+ var content = fs . readFileSync ( srcFile ) ;
58
+ fs . writeFileSync ( destFile , content ) ;
72
59
} ;
73
60
74
-
75
61
var config = {
76
62
pkg : grunt . file . readJSON ( "package.json" ) ,
77
63
clean : { } ,
78
64
template : { } ,
79
65
copy : { } ,
80
-
81
66
shell : {
82
67
start : { command : "jekyll serve --watch" } ,
83
68
update : { command : getUpdateCommands ( ) } ,
84
69
downloadModules : { command : getModuleRepoCommands ( ) } ,
85
70
downloadThemes : { command : getThemeRepoCommands ( ) } ,
86
- copyIcon : { command : function ( ) { getCopyIconCommand ( ) ; } }
71
+
72
+ // builds the module documentation into /modules/[MODULE_FOLDER]
73
+ buildModuleDoc : {
74
+ command : [
75
+ "cd repos/module-form_builder" ,
76
+ "jekyll build --config _config_docs.yml --destination ../../modules/module-form_builder"
77
+ ] . join ( '&&' )
78
+ }
79
+
87
80
}
88
81
} ;
89
82
@@ -108,7 +101,7 @@ module.exports = function(grunt) {
108
101
grunt . registerTask ( "init" , [ "shell:downloadModules" , "shell:downloadThemes" , "createModuleListFiles" ] ) ;
109
102
110
103
// updates the content of the external repos and rebuilds
111
- grunt . registerTask ( "update" , [ "shell:update" , "createModuleListFiles" ] ) ;
104
+ grunt . registerTask ( "update" , [ "shell:update" , "createModuleListFiles" , "shell:buildModuleDoc" ] ) ;
112
105
113
106
// starts the server
114
107
grunt . registerTask ( "start" , [ "shell:start" ] ) ;
0 commit comments