Skip to content

Commit

Permalink
fix: template file reading path
Browse files Browse the repository at this point in the history
- fix file reading issues in templates
  • Loading branch information
sinha-sahil committed Jan 1, 2024
1 parent 03c2404 commit 004d45b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .changeset/friendly-comics-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'type-crafter': patch
---

fix: issue with template file path in reading

- fixed template directory not found issue
7 changes: 4 additions & 3 deletions src/utils/file-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ async function checkFileNameCase(filePath: string): Promise<boolean> {

export async function readFile(
filePath: string,
useCurrentWorkingDirectory: boolean = true
useCurrentWorkingDirectory: boolean = true,
caseSensitive: boolean = false
): Promise<string> {
if (!(await checkFileNameCase(filePath))) {
if (caseSensitive && !(await checkFileNameCase(filePath))) {
throw new Error(`File not found: ${filePath}`);
}
const data = await fs.readFile(resolveFilePath(filePath, useCurrentWorkingDirectory), 'utf-8');
Expand Down Expand Up @@ -89,6 +90,6 @@ export async function writeFile(
}

export async function readYaml(filePath: string): Promise<unknown> {
const fileData = await readFile(filePath);
const fileData = await readFile(filePath, true, true);
return yaml.parse(fileData);
}

0 comments on commit 004d45b

Please sign in to comment.