import fs from 'fs';
import path from 'path';

export function writeFileToLocalCache(fileNameWithExtension: string, fileContents: string) {
    const folderPath = path.join(process.cwd(), '.debug', '.cache');
    const filePath = path.join(folderPath, fileNameWithExtension);


    try {
        // Create the folder if it doesn't exist
        if (!fs.existsSync(folderPath)) {
            fs.mkdirSync(folderPath, { recursive: true });
        }

        // Write the data to the file
        fs.writeFileSync(filePath, fileContents);

        console.log(`File "${filePath}" created successfully.`);
    } catch (error) {
        console.error('Error creating the file:', error);
    }
}
