Skip to content
This repository was archived by the owner on Apr 26, 2022. It is now read-only.

Commit 3b5aeef

Browse files
committed
additional minor fix for append
1 parent 8b8bb3c commit 3b5aeef

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-plop",
3-
"version": "0.21.0",
3+
"version": "0.22.0",
44
"description": "programmatic plopping for fun and profit",
55
"main": "lib/index.js",
66
"types": "index.d.ts",

src/actions/append.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,18 @@ const doAppend = function*(data, cfg, plop, fileData) {
1515
// if the appended string should be unique (default),
1616
// remove any occurence of it (but only if pattern would match)
1717

18+
const { separator = '\n' } = cfg;
1819
if (cfg.unique !== false) {
1920
// only remove after "pattern", so that we remove not too much accidentally
2021
const parts = fileData.split(cfg.pattern);
2122
const lastPart = parts[parts.length - 1];
2223
const lastPartWithoutDuplicates = lastPart.replace(
23-
new RegExp(stringToAppend, 'g'),
24+
new RegExp(separator + stringToAppend, 'g'),
2425
''
2526
);
2627
fileData = fileData.replace(lastPart, lastPartWithoutDuplicates);
2728
}
2829

29-
const { separator = '\n' } = cfg;
30-
3130
// add the appended string to the end of the "fileData" if "pattern"
3231
// was not provided, i.e. null or false
3332
if (!cfg.pattern) {

0 commit comments

Comments
 (0)