Temporary directory management.
import { create, remove, tmpDir } from '@epubknowledge/common/tmp'| Export | Description |
|---|---|
tmpDir |
The value of process.env.TMP_DIR (read from .env at startup) |
create(env?, allowEnvWrite?) |
Creates a tmp directory. env accepts string | boolean: true, 'true', or NODE_ENV='development' reuse TMP_DIR; 'test' does the same and also logs the path; all other values create an auto-cleaned tmp dir. Pass allowEnvWrite=true if you want a missing TMP_DIR written into an existing .env file. |
remove(result) |
Empties the tmp directory and calls the cleanup callback if present |
If TMP_DIR is missing and allowEnvWrite is false, the helper logs the generated directory and continues with that temporary path for the current run. It only writes TMP_DIR into .env when allowEnvWrite=true and the .env file already exists.