Created
December 13, 2018 17:25
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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