Fix bug causing extra Node doc files to not be deleted (#1637)

Fix bug causing extra Node doc files to not be deleted
This commit is contained in:
Christina Holland
2019-03-27 13:25:51 -07:00
committed by GitHub
parent 69e7630e3a
commit 7b56d10b30
+7 -3
View File
@@ -182,8 +182,10 @@ function checkForUnlistedFiles(filenamesFromToc, shouldRemove) {
filename !== 'globals'
) {
if (shouldRemove) {
console.log(`REMOVING ${filename} - not listed in toc.yaml.`);
removePromises.push(() => fs.unlink(`${docPath}/${filename}`));
console.log(
`REMOVING ${docPath}/${filename}.html - not listed in toc.yaml.`
);
removePromises.push(fs.unlink(`${docPath}/${filename}.html`));
} else {
// This is just a warning, it doesn't need to finish before
// the process continues.
@@ -195,7 +197,9 @@ function checkForUnlistedFiles(filenamesFromToc, shouldRemove) {
}
});
if (shouldRemove) {
return Promise.all(removePromises).then(() => htmlFiles);
return Promise.all(removePromises).then(() =>
htmlFiles.filter(filename => filenamesFromToc.includes(filename))
);
} else {
return htmlFiles;
}