All files / src init.js

0% Statements 0/13
0% Branches 0/2
0% Functions 0/1
0% Lines 0/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 28 29 30 31 32 33 34                                                                   
const fs = require('fs-extra');
const path = require('node:path');
const Logger = require('./utils/logger');
const outputDir = path.join(process.cwd(), '.cache');
const initFlagPath = path.join(outputDir, 'init.flag');
 
async function initialize() {
    try {
        // Ensure the .cache directory exists
        await fs.ensureDir(outputDir);
 
        // Check if the init script has already run
        if (await fs.pathExists(initFlagPath)) {
            return;
        }
 
        // Place the init script here
 
        // End of the init script
 
        // Create the init flag file
        await fs.writeFile(initFlagPath, 'Initialization completed.');
 
        Logger.success('Initialization complete.');
    } catch (error) {
        Logger.error('Initialization failed', {
            context: 'Failed to set up spec-up-t boilerplate files',
            hint: 'Ensure you have write permissions in the current directory. Try running with appropriate permissions or in a different directory',
            details: error.message
        });
    }
}
 
module.exports = { initialize };