Skip to content

Commit

Permalink
fix: createFiles function
Browse files Browse the repository at this point in the history
  • Loading branch information
iwaduarte committed Oct 13, 2022
1 parent 90a9a58 commit 2a9e396
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions files.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ const createFolders = (folders = []) =>
const createFiles = ({ files = [], src = '', dest = '', opts }) =>
Promise.all(
files.map(async file => {
const { fileName, mode = MODE_0666, output, prettify } = typeof file === `string` ? { filename: file } : file;
const fileTemplate = await fsPromises.readFile(join(src, fileName), 'utf-8');
const _fileObject = fileName.includes('.js') ? eval(fileTemplate) : fileTemplate;
const { filename, mode = MODE_0666, output, prettify } = typeof file === `string` ? { filename: file } : file;
const fileTemplate = await fsPromises.readFile(join(src, filename), 'utf-8');
const _fileObject = filename.includes('.js') ? eval(fileTemplate) : fileTemplate;
const fileObject = prettify ? prettier.format(_fileObject, { filepath: prettify }) : _fileObject;
const newFileName = output ? output : fileName;
const newFileName = output ? output : filename;

return fsPromises.writeFile(join(dest, newFileName), fileObject, {
mode
Expand Down

0 comments on commit 2a9e396

Please sign in to comment.