@@ -185,10 +185,21 @@ const activate = context => {
185
185
return cb ( )
186
186
}
187
187
188
- let exportDir = root + '/src/'
189
- if ( ! fs . existsSync ( exportDir ) ) fs . mkdirSync ( exportDir )
190
- exportDir += doc . cat + '/'
191
- if ( ! fs . existsSync ( exportDir ) ) fs . mkdirSync ( exportDir )
188
+ let exportDir = root + 'src/' + doc . cat + '/'
189
+
190
+ if ( doc . cat == "CLS" ) {
191
+
192
+ let oldFilePath = doc . name . split ( "." ) ;
193
+ let dirElements = oldFilePath . length - 2 ;
194
+ let newFileName = oldFilePath . slice ( dirElements , dirElements + 2 ) . toString ( ) . replace ( / , / g , "." ) ;
195
+ let newFilePath = oldFilePath . slice ( 0 , dirElements ) . toString ( ) . replace ( / , / g , "/" ) + "/" ;
196
+
197
+ exportDir += newFilePath ;
198
+ doc . name = newFileName ;
199
+
200
+ }
201
+
202
+ if ( ! fs . existsSync ( exportDir ) ) mkdirSyncP ( exportDir )
192
203
193
204
const filepath = exportDir + doc . name
194
205
fs . writeFileSync ( filepath , doc . content . join ( '\n' ) )
@@ -199,6 +210,18 @@ const activate = context => {
199
210
200
211
}
201
212
213
+ const mkdirSyncP = ( pathToFile ) => {
214
+ if ( ! fs . existsSync ( pathToFile ) ) {
215
+ let dirName = "" ;
216
+ let filePathSplit = pathToFile . split ( '/' ) ;
217
+ for ( let index = 0 ; index < filePathSplit . length ; index ++ ) {
218
+ dirName += filePathSplit [ index ] + '/' ;
219
+ if ( ! fs . existsSync ( dirName ) )
220
+ fs . mkdirSync ( dirName ) ;
221
+ }
222
+ }
223
+ }
224
+
202
225
const load = ( doc , cb ) => {
203
226
204
227
const loaded = ( err , json ) => {
@@ -231,15 +254,14 @@ const activate = context => {
231
254
} )
232
255
}
233
256
234
-
235
257
const onGetDocs = ( err , json ) => {
236
-
258
+
237
259
if ( err ) return log ( 'getDocs ERROR' )
238
260
239
261
const list = json . result . content
240
262
log ( '' )
241
263
log ( 'list: ' + list . length )
242
- const docs = list . filter ( doc => ( doc . cat !== 'CSP' ) && ( doc . name . substring ( 0 , 1 ) !== '%' ) && ( doc . name . substring ( 0 , 12 ) !== 'INFORMATION.' ) )
264
+ const docs = list . filter ( doc => ( doc . cat !== 'CSP' ) && ( doc . name . substring ( 0 , 1 ) !== '%' ) && ( doc . name . substring ( 0 , 12 ) !== 'INFORMATION.' ) )
243
265
log ( 'without % and CSP and INFORMATION: ' + docs . length )
244
266
log ( '' )
245
267
exportDocs ( docs , ( ) => {
0 commit comments