How does one create an empty directory via a yeoman generator?
I've looked at mem-fs-editor, but as far as I can tell, directories are only created when a child file is created. I've tried creating a file in a sub directory and then deleting the file, but this doesn't work (I assume because mem-fs is prebuilt completely in memory, when it comes to write to disk, empty directories are not written).
mem-fs-editor (the file library used by Yeoman) do not support empty folders. This is very similar to how git work, the internal only keep track of files.
One option is to add .gitkeep
or other empty files in those directory. That's my recommended solution as this will fix the issues you'll have anyway using git.
Another option is to use mkdirp
:
var mkdirp = require('mkdirp');
// In your generator
mkdirp.sync('/some/path/to/dir/');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With