Skip to content

Commit c59a3fc

Browse files
committed
fix: --rewrite flag in generate-templates command
1 parent c58eea5 commit c59a3fc

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

src/commands/generate-templates/templates-gen-process.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,31 @@ class TemplatesGenProcess {
6262
const templateEjsPathExist = this.fileSystem.pathIsExist(templateEjsPath);
6363
const templateEtaPathExist = this.fileSystem.pathIsExist(templateEtaPath);
6464

65-
if (this.config.rewrite || (!templateEjsPathExist && !templateEtaPathExist)) {
65+
const templateNotExist = !templateEjsPathExist && !templateEtaPathExist;
66+
67+
if (templateNotExist) {
6668
this.fileSystem.createFile({
6769
path: outputPath,
6870
fileName: template.name,
6971
content: template.content,
7072
withPrefix: false,
7173
});
72-
} else if (templateEjsPathExist) {
73-
this.fileSystem.createFile({
74-
path: outputPath,
75-
fileName: `${templateName}.ejs`,
76-
content: template.content,
77-
withPrefix: false,
78-
});
79-
} else if (templateEtaPathExist) {
80-
this.fileSystem.createFile({
81-
path: outputPath,
82-
fileName: `${templateName}.eta`,
83-
content: template.content,
84-
withPrefix: false,
85-
});
74+
} else if (this.config.rewrite) {
75+
if (templateEjsPathExist) {
76+
this.fileSystem.createFile({
77+
path: outputPath,
78+
fileName: `${templateName}.ejs`,
79+
content: template.content,
80+
withPrefix: false,
81+
});
82+
} else if (templateEtaPathExist) {
83+
this.fileSystem.createFile({
84+
path: outputPath,
85+
fileName: `${templateName}.eta`,
86+
content: template.content,
87+
withPrefix: false,
88+
});
89+
}
8690
}
8791
});
8892

0 commit comments

Comments
 (0)