Skip to content

Commit

Permalink
fix(pencil): ensure parent directory of output file exsits
Browse files Browse the repository at this point in the history
  • Loading branch information
PipecraftNet committed Sep 23, 2021
1 parent 2850c4b commit 80e54cf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import renderHbs from 'geneasy-handlebars';
import parse from 'geneasy-yaml';
import fsExtra from 'fs-extra';

const { readFile, writeFile } = fsExtra;
const { readFile, writeFile, ensureFile } = fsExtra;

export function register() {}
export async function render(template, dataFiles, output) {
Expand All @@ -14,6 +14,7 @@ export async function render(template, dataFiles, output) {
template = await readFile(template, 'utf-8');
const result = await renderHbs(template, data);
if (output) {
await ensureFile(output);
await writeFile(output, result);
} else {
console.log(result);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "geneasy",
"version": "0.1.1",
"version": "0.1.2",
"description": "A command line tool that can easily generate HTML, Markdown documents, etc.",
"type": "module",
"bin": {
Expand Down

0 comments on commit 80e54cf

Please sign in to comment.