keithamus / hbs-cli

A CLI for handlebars
43 stars 26 forks source link

feat: use `fs-extra`'s outputFile to create output folder if needed #52

Closed rmobis closed 5 years ago

rmobis commented 5 years ago

By default, writeFile will not create the output directory if it does not exist and, as such, will cause an error to be thrown when it doesn't. This is a nuisance because dist folder are usually not commited to the repository so you either have to create the folder structure and commit it with a .gitignore file, or run a script to create these folders pre-build.

Using fs-extra's outputFile method instead of fs-promise's writeFile does create the folder though, avoiding all this nuisance. This PR does just that. Please note that fs-extra is a drop-in replacement for fs/fs-promise - which, by the way, has been deprecated -, so I don't believe there'll be any problems.

rmobis commented 5 years ago

Ok, so, apparently fs-extra doesn't support Node.js versions prior to 5.0. That means this PR becomes a breaking change, so I'm not 100% sure if you'll want to merge it. It's worth noting though that Node 4.0 and 5.0 have long been discontinued and 6.0 (Boron) will reach end of life in April 2019, just a few months away.

Edit: Node 4.0 probably works with --harmony flag.

keithamus commented 5 years ago

What about altering this to use mkdirp instead? I believe that supports older versions of node, and running it on an existing directory is a noop.

rmobis commented 5 years ago

That sounds like a better idea, ye. Closing this in favor of #53.