honkit
Version:
HonKit is building beautiful books using Markdown.
46 lines (45 loc) • 1.82 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.isStructureFile = isStructureFile;
exports.shouldFullRebuild = shouldFullRebuild;
const path_1 = __importDefault(require("path"));
/**
* Determine if a file change requires a full rebuild based on the file path
*
* Full rebuild is needed when:
* - SUMMARY.md is changed (book structure changed)
* - GLOSSARY.md is changed (glossary definitions changed)
* - book.json or book.js is changed (configuration changed)
*
* @param filepath - The absolute path of the changed file
* @returns true if full rebuild is needed, false for incremental build
*/
function isStructureFile(filepath) {
const filename = path_1.default.basename(filepath);
const lowerFilename = filename.toLowerCase();
// Structure files that require full rebuild
const structureFiles = ["summary.md", "glossary.md", "book.json", "book.js"];
return structureFiles.includes(lowerFilename);
}
/**
* Determine if a file change requires a full rebuild
*
* Full rebuild is needed when:
* - Structure files are changed (SUMMARY.md, GLOSSARY.md, book.json, book.js)
* - Files are added or removed (to update asset list and page structure)
*
* @param filepath - The absolute path of the changed file
* @param eventType - The type of file change event
* @returns true if full rebuild is needed, false for incremental build
*/
function shouldFullRebuild(filepath, eventType) {
// File additions or deletions always require full rebuild
if (eventType === "add" || eventType === "unlink") {
return true;
}
// Structure files require full rebuild
return isStructureFile(filepath);
}