Skip to content

Commit 6199383

Browse files
committed
fix: 优化文件名判断逻辑
- 将判断逻辑从 sourcePath 改为 sourceFileName,提高代码准确性和可读性 - 优化了 EJS 文件、下划线文件和点文件的判断逻辑
1 parent a21b9a8 commit 6199383

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Creator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ export class Creator<T extends Record<string, unknown>> extends TypedEvents<{
148148
const sourceFolder = path.dirname(sourcePath);
149149
const sourceFile = path.join(context.templateRoot, sourcePath);
150150

151-
const isEjsFile = EJS_FILE_REGEX.test(sourcePath);
152-
const isUnderscoreFile = sourcePath.startsWith(UNDERSCORE_FILE_PREFIX);
153-
const isDotFile = !isUnderscoreFile && sourcePath.startsWith(DOT_FILE_PREFIX);
151+
const isEjsFile = EJS_FILE_REGEX.test(sourceFileName);
152+
const isUnderscoreFile = sourceFileName.startsWith(UNDERSCORE_FILE_PREFIX);
153+
const isDotFile = !isUnderscoreFile && sourceFileName.startsWith(DOT_FILE_PREFIX);
154154

155155
let start = 0;
156156
let end = undefined;

0 commit comments

Comments
 (0)