-
Notifications
You must be signed in to change notification settings - Fork 286
Open
Description
Description:
When using the append action in Plop, if the target file already contains the literal "$`"(dollar + backquote), it gets removed during the append operation. This issue appears to occur in the implementation of the append action, where String.replace interprets "$" as a special replacement pattern (representing the text preceding the match) rather than as a literal string.
The problem is placed when regular expression strings are written in JavaScript source code.
Steps to Reproduce:
input.txt
$`$`
plopfile.ts
import type { NodePlopAPI } from "plop";
export default function (plop: NodePlopAPI) {
plop.setGenerator("test", {
description: "test",
prompts: [
{
type: "input",
name: "name",
message: "input name",
},
],
actions: [
{
type: "append",
path: "input.txt",
template: 'console.log("{{name}}");',
},
],
});
}
Actual Outcome
console.log("hoge");
Additional Context:
The issue seems to be in the implementation of the append action logic in append.js A potential fix might involve escaping all $ characters (e.g., replacing $ with $$) in the replacement string to ensure they remain intact.
Metadata
Metadata
Assignees
Labels
No labels