Skip to content

Commit af69444

Browse files
committed
Ensure addMany actions strip extensions correctly on dot files
1 parent 4433a20 commit af69444

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

packages/node-plop/src/actions/addMany.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function stripExtensions(shouldStrip, fileName) {
106106
)
107107
return fileName;
108108

109-
return path.parse(maybeFile.name).ext !== ""
109+
return path.parse(maybeFile.name).ext !== "" || maybeFile.name.startsWith(".")
110110
? path.join(maybeFile.dir, maybeFile.name)
111111
: fileName;
112112
}

packages/node-plop/tests/addMany-strip-extensions/addMany-strip-extensions.spec.js

+14
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,18 @@ describe("addMany-strip-extensions", function () {
3636
expect(fs.existsSync(nonSpecPath)).toBe(true);
3737
expect(fs.existsSync(specPath)).toBe(true);
3838
});
39+
40+
test("Check that dot files generated without hbs extension", () => {
41+
const dotPath = path.resolve(
42+
testSrcPath,
43+
"remove-dotfile-hbs/.gitignore"
44+
);
45+
const dotPathWithExtension = path.resolve(
46+
testSrcPath,
47+
"remove-dotfile-hbs/.eslintrc.cjs"
48+
);
49+
50+
expect(fs.existsSync(dotPath)).toBe(true);
51+
expect(fs.existsSync(dotPathWithExtension)).toBe(true);
52+
});
3953
});

packages/node-plop/tests/addMany-strip-extensions/plop-templates/remove-dotfile-hbs/.eslintrc.cjs.hbs

Whitespace-only changes.

packages/node-plop/tests/addMany-strip-extensions/plop-templates/remove-dotfile-hbs/.gitignore.hbs

Whitespace-only changes.

packages/node-plop/tests/addMany-strip-extensions/plopfile.js

+8
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ export default function (plop) {
3030
templateFiles: "plop-templates/remove-all/*",
3131
abortOnFail: true,
3232
},
33+
{
34+
type: "addMany",
35+
destination: "src/",
36+
stripExtensions: ["hbs"],
37+
templateFiles: "plop-templates/remove-dotfile-hbs/*",
38+
abortOnFail: true,
39+
globOptions: { dot: true },
40+
},
3341
],
3442
});
3543
}

0 commit comments

Comments
 (0)