Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 23ff8aa

Browse files
chalinkwalrath
authored andcommitted
chore: improve UX of build w/o API (#2265)
Just do a full build if no API docs currently exist rather than building the site and then aborting with an error message at the end of it all.
1 parent 3fa68cd commit 23ff8aa

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

gulpfile.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,15 +889,16 @@ function harpCompile() {
889889
env({ vars: { NODE_ENV: "production" } });
890890
gutil.log("NODE_ENV: " + process.env.NODE_ENV);
891891

892-
if(skipLangs && fs.existsSync('www')) {
892+
if(skipLangs && fs.existsSync('www') && backupApiHtmlFilesExist('www')) {
893893
gutil.log(`Harp site recompile: skipping recompilation of API docs for [${skipLangs}]`);
894894
gutil.log(`API docs will be copied from existing www folder.`)
895895
del.sync('www-backup'); // remove existing backup if it exists
896896
renameIfExistsSync('www', 'www-backup');
897897
} else {
898898
gutil.log(`Harp full site compile, including API docs for all languages.`);
899899
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.`);
901902
}
902903

903904
var deferred = Q.defer();
@@ -1048,6 +1049,21 @@ function restoreApiHtml() {
10481049
});
10491050
}
10501051

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+
10511067
// Copies fileNames into destPaths, setting the mode of the
10521068
// files at the destination as optional_destFileMode if given.
10531069
// returns a promise

0 commit comments

Comments
 (0)