All files / lib create-file.js

71.43% Statements 5/7
50% Branches 1/2
100% Functions 2/2
71.43% Lines 5/7

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 161x     1x 1x 1x     1x              
import fs from 'fs'
 
export function createFile(fileName, data) {
  try {
    fs.writeFile(`${process.cwd()}/${fileName}`, data, 'utf8', function (err) {
      Iif (err) {
        throw new Error(err)
      }
      console.log('\x1b[32m', `Your file has been saved in ${process.cwd()}/output/${fileName}.`);
    });
  }
  catch (err) {
    console.error(err)
  }
}