@@ -35,6 +35,7 @@ const SITE_CONFIG_DEFAULT = {
35
35
} ,
36
36
] ,
37
37
ignore : [
38
+ '_markbind/logs/*' ,
38
39
'_site/*' ,
39
40
'*.json' ,
40
41
'*.md' ,
@@ -51,6 +52,8 @@ const USER_VARIABLES_DEFAULT = '<span id="example">\n'
51
52
+ 'More generally, surround the segment\'s id with double curly braces.\n'
52
53
+ '</span>' ;
53
54
55
+ const GENERATE_SITE_LOGGING_KEY = 'Generate Site' ;
56
+
54
57
function Site ( rootPath , outputPath ) {
55
58
this . rootPath = rootPath ;
56
59
this . outputPath = outputPath ;
@@ -71,6 +74,7 @@ function Site(rootPath, outputPath) {
71
74
*/
72
75
73
76
function rejectHandler ( reject , error , removeFolders ) {
77
+ logger . warn ( error ) ;
74
78
Promise . all ( removeFolders . map ( folder => fs . removeAsync ( folder ) ) )
75
79
. then ( ( ) => {
76
80
reject ( error ) ;
@@ -242,6 +246,7 @@ Site.prototype.collectUserDefinedVariablesMap = function () {
242
246
243
247
Site . prototype . generate = function ( baseUrl ) {
244
248
// Create the .tmp folder for storing intermediate results.
249
+ logger . profile ( GENERATE_SITE_LOGGING_KEY ) ;
245
250
fs . emptydirSync ( this . tempPath ) ;
246
251
// Clean the output folder; create it if not exist.
247
252
fs . emptydirSync ( this . outputPath ) ;
@@ -255,7 +260,8 @@ Site.prototype.generate = function (baseUrl) {
255
260
. then ( resolve )
256
261
. catch ( ( error ) => {
257
262
rejectHandler ( reject , error , [ this . tempPath , this . outputPath ] ) ;
258
- } ) ;
263
+ } )
264
+ . finally ( ( ) => logger . profile ( GENERATE_SITE_LOGGING_KEY ) ) ;
259
265
} ) ;
260
266
} ;
261
267
@@ -277,6 +283,7 @@ Site.prototype.buildSourceFiles = function () {
277
283
278
284
Site . prototype . _rebuildAffectedSourceFiles = function ( filePaths ) {
279
285
const uniquePaths = _ . uniq ( filePaths ) ;
286
+ logger . verbose ( `Rebuild affected paths: ${ uniquePaths } ` ) ;
280
287
return new Promise ( ( resolve , reject ) => {
281
288
this . regenerateAffectedPages ( uniquePaths )
282
289
. then ( ( ) => fs . removeAsync ( this . tempPath ) )
@@ -366,7 +373,11 @@ Site.prototype.generatePages = function () {
366
373
pageTemplate : this . pageTemplate ,
367
374
} ) ) ;
368
375
this . pageModels . forEach ( ( page ) => {
369
- processingFiles . push ( page . generate ( builtFiles ) ) ;
376
+ processingFiles . push ( page . generate ( builtFiles )
377
+ . catch ( ( err ) => {
378
+ logger . error ( err ) ;
379
+ return Promise . reject ( new Error ( `Error while generating ${ page . sourcePath } ` ) ) ;
380
+ } ) ) ;
370
381
} ) ;
371
382
return new Promise ( ( resolve , reject ) => {
372
383
Promise . all ( processingFiles )
@@ -385,7 +396,11 @@ Site.prototype.regenerateAffectedPages = function (filePaths) {
385
396
const processingFiles = [ ] ;
386
397
this . pageModels . forEach ( ( page ) => {
387
398
if ( filePaths . some ( filePath => page . includedFiles [ filePath ] ) ) {
388
- processingFiles . push ( page . generate ( builtFiles ) ) ;
399
+ processingFiles . push ( page . generate ( builtFiles )
400
+ . catch ( ( err ) => {
401
+ logger . error ( err ) ;
402
+ return Promise . reject ( new Error ( `Error while generating ${ page . sourcePath } ` ) ) ;
403
+ } ) ) ;
389
404
}
390
405
} ) ;
391
406
0 commit comments