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.
This commit is contained in:
parent
3fa68cd7ac
commit
23ff8aaca8
20
gulpfile.js
20
gulpfile.js
|
@ -889,7 +889,7 @@ function harpCompile() {
|
||||||
env({ vars: { NODE_ENV: "production" } });
|
env({ vars: { NODE_ENV: "production" } });
|
||||||
gutil.log("NODE_ENV: " + process.env.NODE_ENV);
|
gutil.log("NODE_ENV: " + process.env.NODE_ENV);
|
||||||
|
|
||||||
if(skipLangs && fs.existsSync('www')) {
|
if(skipLangs && fs.existsSync('www') && backupApiHtmlFilesExist('www')) {
|
||||||
gutil.log(`Harp site recompile: skipping recompilation of API docs for [${skipLangs}]`);
|
gutil.log(`Harp site recompile: skipping recompilation of API docs for [${skipLangs}]`);
|
||||||
gutil.log(`API docs will be copied from existing www folder.`)
|
gutil.log(`API docs will be copied from existing www folder.`)
|
||||||
del.sync('www-backup'); // remove existing backup if it exists
|
del.sync('www-backup'); // remove existing backup if it exists
|
||||||
|
@ -897,7 +897,8 @@ function harpCompile() {
|
||||||
} else {
|
} else {
|
||||||
gutil.log(`Harp full site compile, including API docs for all languages.`);
|
gutil.log(`Harp full site compile, including API docs for all languages.`);
|
||||||
if (skipLangs)
|
if (skipLangs)
|
||||||
gutil.log(`Ignoring API docs skip set (${skipLangs}) because full site has not been built yet.`);
|
gutil.log(`Ignoring API docs skip set (${skipLangs}) because full ` +
|
||||||
|
`site has not been built yet or some API HTML files are missing.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
var deferred = Q.defer();
|
var deferred = Q.defer();
|
||||||
|
@ -1048,6 +1049,21 @@ function restoreApiHtml() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For each lang in skipLangs, ensure API dir exists in www-backup
|
||||||
|
function backupApiHtmlFilesExist(folderName) {
|
||||||
|
const vers = 'latest';
|
||||||
|
var result = 1;
|
||||||
|
skipLangs.forEach(lang => {
|
||||||
|
const relApiDir = path.join('docs', lang, vers, 'api');
|
||||||
|
const backupApiSubdir = path.join(folderName, relApiDir);
|
||||||
|
if (!fs.existsSync(backupApiSubdir)) {
|
||||||
|
gutil.log(`WARNING: API docs HTML folder doesn't exist: ${backupApiSubdir}`);
|
||||||
|
result = 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Copies fileNames into destPaths, setting the mode of the
|
// Copies fileNames into destPaths, setting the mode of the
|
||||||
// files at the destination as optional_destFileMode if given.
|
// files at the destination as optional_destFileMode if given.
|
||||||
// returns a promise
|
// returns a promise
|
||||||
|
|
Loading…
Reference in New Issue