Skip to content

Instantly share code, notes, and snippets.

@l3aconator
Created December 13, 2018 17:25
Show Gist options
  • Save l3aconator/886de61420ca1368429f4fcb461e181d to your computer and use it in GitHub Desktop.
Save l3aconator/886de61420ca1368429f4fcb461e181d to your computer and use it in GitHub Desktop.
Node script to write filename and extension to filesystem based on an array of filenames. Helpful for creating a list of container files to copy and paste content into. My use case was taking an array of svg icon names to then have content dumped into them.
import fs from 'fs';
const folderUnderDirname = 'folder';
const fileExtension = '.html.twig';
const files = [
'filename-goes-here',
];
files.forEach(async file => {
await fs.promises.writeFile(`${__dirname}/${folderUnderDirname}/${file}${fileExtension}`, file, { flag: 'wx' });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment