import fs from "node:fs";

export function getDataDirectory(): string {
	const dataDirectory = process.env.DATA_DIRECTORY;

	if (!dataDirectory) {
		console.error("ERROR: DATA_DIRECTORY environment variable is not set");
		process.exit(1);
	}

	// Create directory recursively if it doesn't exist
	if (!fs.existsSync(dataDirectory)) {
		fs.mkdirSync(dataDirectory, { recursive: true });
	}

	return dataDirectory;
}
