Skip to content

Latest commit

 

History

History
29 lines (26 loc) · 2.54 KB

File metadata and controls

29 lines (26 loc) · 2.54 KB

@epubknowledge/common/dir

Directory inspection and manipulation.

import {
  isDir,
  dirCopy,
  dirEmpty,
  isDirEmpty,
  verifyBookDir,
  bookDir,
  getDirContents,
  isOEBPS,
  OEBPSError,
} from '@epubknowledge/common/dir'
Export Description
isDir(dir) Returns true if the path exists and is a directory
dirCopy({ inputDir, outputDir }) Copies a directory tree; returns true or DirError
dirEmpty(dir) Empties a directory without removing it
isDirEmpty(dir) Returns true if the directory has no entries
verifyBookDir(dir) Resolves a path to an absolute path and validates that it looks like an EPUB directory; returns the absolute path or DirError
bookDir(dir) Validates that a directory looks like an EPUB book (contains META-INF, OEBPS, etc.); returns the absolute path or DirError
getDirContents(dir, ext?) Lists files in a directory filtered by extension (default xhtml)
OEBPSError Typed error thrown by isOEBPS(dir) when the path is invalid, empty, or not named OEBPS
isOEBPS(dir) Returns true when the path is a non-empty OEBPS directory; otherwise logs a chalk-formatted error and throws OEBPSError so the caller can decide how to handle failure