Skip to content

Commit

Permalink
Merge pull request #352 from trmnl-cmdr/fix-append-dynamic-templatefile
Browse files Browse the repository at this point in the history
fix: Append action's templateFile string not processed by handlebars
  • Loading branch information
crutchcorn committed Feb 8, 2023
2 parents 9a4cf25 + b106460 commit 8e302df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/node-plop/src/actions/append.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as fspp from "../fs-promise-proxy.js";

import {
getRenderedTemplate,
getRenderedTemplatePath,
makeDestPath,
throwStringifiedError,
getRelativeToBasePath,
Expand Down Expand Up @@ -52,6 +53,7 @@ export default async function (data, cfg, plop) {
throw "File does not exist";
} else {
let fileData = await fspp.readFile(fileDestPath);
cfg.templateFile = getRenderedTemplatePath(data, cfg, plop);
fileData = await doAppend(data, cfg, plop, fileData);
await fspp.writeFile(fileDestPath, fileData);
}
Expand Down
6 changes: 6 additions & 0 deletions packages/node-plop/tests/dynamic-template-file/plopfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ export default function (plop) {
path: "src/change-me.txt",
templateFile: "plop-templates/change-me.txt",
},
{
type: "append",
path: "src/change-me.txt",
pattern: /(-- APPEND ITEMS HERE --)/gi,
templateFile: "plop-templates/{{dashCase kind}}.txt",
},
{
type: "modify",
path: "src/change-me.txt",
Expand Down

0 comments on commit 8e302df

Please sign in to comment.