UNPKG

honkit

Version:

HonKit is building beautiful books using Markdown.

29 lines (28 loc) 1.02 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createTmpDirWithRealPath = void 0; const path_1 = __importDefault(require("path")); const os_1 = __importDefault(require("os")); const fs_1 = __importDefault(require("fs")); const getRealTmpRoot = () => { try { return fs_1.default.realpathSync.native(os_1.default.tmpdir()); } catch { return os_1.default.tmpdir(); } }; /** * Create a temporary directory with a real path * ebook-convert requires a real path to work * https://github.com/honkit/honkit/issues/394 * @param prefix "honkit-" */ const createTmpDirWithRealPath = (prefix = "honkit-") => { const tmpDir = fs_1.default.mkdtempSync(path_1.default.join(getRealTmpRoot(), prefix)); return fs_1.default.realpathSync.native(tmpDir); }; exports.createTmpDirWithRealPath = createTmpDirWithRealPath;