honkit
Version:
HonKit is building beautiful books using Markdown.
31 lines (30 loc) • 1.17 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = __importDefault(require("path"));
const path_2 = __importDefault(require("../../utils/path"));
const location_1 = __importDefault(require("../../utils/location"));
const OUTPUT_EXTENSION = ".html";
/**
* Convert a filePath (absolute) to a filename for output
*
* @param {Output} output
* @param {string} filePath
* @return {string}
*/
function fileToOutput(output, filePath) {
const book = output.getBook();
const readme = book.getReadme();
const fileReadme = readme.getFile();
if (path_1.default.basename(filePath, path_1.default.extname(filePath)) == "README" ||
(fileReadme.exists() && filePath == fileReadme.getPath())) {
filePath = path_1.default.join(path_1.default.dirname(filePath), `index${OUTPUT_EXTENSION}`);
}
else {
filePath = path_2.default.setExtension(filePath, OUTPUT_EXTENSION);
}
return location_1.default.normalize(filePath);
}
exports.default = fileToOutput;