-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoutput.utilities.ts
More file actions
27 lines (26 loc) · 937 Bytes
/
output.utilities.ts
File metadata and controls
27 lines (26 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import path from "node:path";
/**
* Resolves the full path for an output file.
*
* Uses the OUTPUT_DIR environment variable if set (for Kubernetes deployments
* with mounted persistent volumes), otherwise defaults to ./output for local
* development runs.
*
* @param filename - Name of the output file (e.g., "events.ics", "data.json")
* @returns Absolute path to the output file
*
* @example
* ```typescript
* // Local development
* getOutputPath('calendar.ics'); // returns './output/calendar.ics'
*
* // Kubernetes deployment with OUTPUT_DIRECTORY=/data/output
* getOutputPath('calendar.ics'); // returns '/data/output/calendar.ics'
* ```
*
* @see {@link https://kubernetes.io/docs/concepts/storage/persistent-volumes/} for PVC configuration
*/
export function getOutputPath(filename: string): string {
const outputDir = process.env["OUTPUT_DIRECTORY"] ?? "./output";
return path.join(outputDir, filename);
}