Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/map-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ export interface MapParserConfig {
* @default undefined
*/
resources?: string[];
/**
* Path to use as the temporary extraction directory. If not provided, a unique
* directory is created automatically under os.tmpdir(). When provided, the caller
* is responsible for ensuring uniqueness across concurrent parses of the same map.
* The directory is deleted by the parser after parsing completes.
* @default undefined
*/
tmpDir?: string;
}

const mapParserDefaultConfig: Partial<MapParserConfig> = {
Expand All @@ -88,7 +96,7 @@ export class MapParser {
const filePath = path.parse(mapFilePath);
const fileName = filePath.name;
const fileExt = filePath.ext;
const tempArchiveDir = path.join(os.tmpdir(), fileName);
const tempArchiveDir = this.config.tmpDir ?? await fs.mkdtemp(path.join(os.tmpdir(), `${fileName}-`));

// register a named handler so we can remove only our listener later
const sigintHandler = async () => this.sigint(tempArchiveDir);
Expand Down
Loading