@@ -889,15 +889,16 @@ function harpCompile() {
889
889
env ( { vars : { NODE_ENV : "production" } } ) ;
890
890
gutil . log ( "NODE_ENV: " + process . env . NODE_ENV ) ;
891
891
892
- if ( skipLangs && fs . existsSync ( 'www' ) ) {
892
+ if ( skipLangs && fs . existsSync ( 'www' ) && backupApiHtmlFilesExist ( 'www' ) ) {
893
893
gutil . log ( `Harp site recompile: skipping recompilation of API docs for [${ skipLangs } ]` ) ;
894
894
gutil . log ( `API docs will be copied from existing www folder.` )
895
895
del . sync ( 'www-backup' ) ; // remove existing backup if it exists
896
896
renameIfExistsSync ( 'www' , 'www-backup' ) ;
897
897
} else {
898
898
gutil . log ( `Harp full site compile, including API docs for all languages.` ) ;
899
899
if ( skipLangs )
900
- gutil . log ( `Ignoring API docs skip set (${ skipLangs } ) because full site has not been built yet.` ) ;
900
+ gutil . log ( `Ignoring API docs skip set (${ skipLangs } ) because full ` +
901
+ `site has not been built yet or some API HTML files are missing.` ) ;
901
902
}
902
903
903
904
var deferred = Q . defer ( ) ;
@@ -1048,6 +1049,21 @@ function restoreApiHtml() {
1048
1049
} ) ;
1049
1050
}
1050
1051
1052
+ // For each lang in skipLangs, ensure API dir exists in www-backup
1053
+ function backupApiHtmlFilesExist ( folderName ) {
1054
+ const vers = 'latest' ;
1055
+ var result = 1 ;
1056
+ skipLangs . forEach ( lang => {
1057
+ const relApiDir = path . join ( 'docs' , lang , vers , 'api' ) ;
1058
+ const backupApiSubdir = path . join ( folderName , relApiDir ) ;
1059
+ if ( ! fs . existsSync ( backupApiSubdir ) ) {
1060
+ gutil . log ( `WARNING: API docs HTML folder doesn't exist: ${ backupApiSubdir } ` ) ;
1061
+ result = 0 ;
1062
+ }
1063
+ } ) ;
1064
+ return result ;
1065
+ }
1066
+
1051
1067
// Copies fileNames into destPaths, setting the mode of the
1052
1068
// files at the destination as optional_destFileMode if given.
1053
1069
// returns a promise
0 commit comments