Skip to content

Commit

Permalink
feat: use mkdirp to create folder before outputing (#53)
Browse files Browse the repository at this point in the history
* feat: use mkdirp to create folder before outputing

* feat: switch to mkdirp-then isntead of mkdirp-promise
  • Loading branch information
rmobis authored and keithamus committed Nov 24, 2018
1 parent f7e35dc commit feacd1c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -59,6 +59,7 @@
"handlebars": "^4.0.5",
"lodash.merge": "^3.3.2",
"minimist": "^1.2.0",
"mkdirp-then": "^1.2.0",
"resolve": "^1.1.6"
},
"devDependencies": {
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Expand Up @@ -7,6 +7,7 @@ import packageJson from '../package.json';
import resolveNode from 'resolve';
import { readFile, writeFile } from 'fs-promise';
import merge from 'lodash.merge';
import mkdirp from 'mkdirp-then';
const debug = require('debug')('hbs');
function resolve(file, options) {
return new Promise((resolvePromise, reject) => resolveNode(file, options, (error, path) => {
Expand Down Expand Up @@ -95,6 +96,7 @@ export async function renderHandlebarsTemplate(
if (stdout) {
await process.stdout.write(htmlContents, 'utf8');
} else {
await mkdirp(outputDirectory);
await writeFile(path, htmlContents, 'utf8');
debug(`Wrote ${path}`);
console.error(`Wrote ${path} from ${file}`);
Expand Down

0 comments on commit feacd1c

Please sign in to comment.