Skip to content

Latest commit

 

History

History
44 lines (34 loc) · 2.92 KB

File metadata and controls

44 lines (34 loc) · 2.92 KB

@epubknowledge/common/objectSetup

Bootstrap helper for CLI scripts and pipeline entry points.

import objectSetup from '@epubknowledge/common/objectSetup'

const result = objectSetup({ i: 'input/dir', o: 'output/dir', e: 'book.epub' })

Resolves input/output paths, sets up a tmp directory, and returns a SetupResult. Respects the BUILD_LOCALLY environment variable to control tmp directory behavior.

Option Description
i Input path (directory or file)
o Output path (optional, defaults to input path)
e EPUB file path — when provided, populates result.epub instead of result.input
locally Passed through to tmp.create() as its env argument; overridden by BUILD_LOCALLY when that variable is set

Returns

Property Type Description
tmp TmpResult Tmp directory descriptor returned by tmp.create(), including dir, nuke, and optional locally fields
input? string Absolute input path when e is not provided
output? string Absolute output path; defaults to o, the resolved input path, or the EPUB parent directory
epub? { filename: string; epubDir: string; path: string; fullPath: string } Present when e is provided
error? string | null Optional field from the shared SetupResult type; objectSetup() does not set it directly

When BUILD_LOCALLY is set, it overrides the locally option before calling tmp.create(). If the resolved value is a string, objectSetup() also copies that string to result.tmp.locally.

Example when e is omitted:

{
  "input": "/workspace/book/OEBPS",
  "output": "/workspace/book/OEBPS",
  "tmp": {
    "dir": "/tmp/tmp-12345",
    "nuke": false,
    "locally": "true"
  }
}