Skip to content

Commit

Permalink
fix: rename folder bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Tsai committed Jan 7, 2025
1 parent 18440aa commit dd24c3e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"license": "ISC",
"dependencies": {
"dotenv": "^16.4.5",
"glob": "^11.0.0",
"glob": "^8.0.3",
"openai": "^4.55.7"
}
}
16 changes: 14 additions & 2 deletions utils/sync-and-translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,27 @@ function getChangedFiles() {
})
.map((line) => {
const [status, ...fileParts] = line.split(/\s+/);
if (status.startsWith("R")) {
const oldPath = fileParts[0];
const newPath = fileParts[1];
if (fs.existsSync(newPath) && fs.lstatSync(newPath).isDirectory()) {
const oldFiles = glob.sync(`${oldPath}/**/*`);
return oldFiles.map((oldFile) => ({
status: "R",
oldFile: oldFile,
file: oldFile.replace(oldPath, newPath),
}));
}
}
if (line.endsWith(".md")) {
if (status.startsWith("R")) {
return { status, oldFile: fileParts[0], file: fileParts[1] };
}
return { status, file: fileParts[0] };
}

return { status, file: fileParts?.[1] ?? fileParts[0] };
});
})
.flat();
return fileChanges;
} catch (error) {
console.error("Error getting changed files:", error);
Expand Down

0 comments on commit dd24c3e

Please sign in to comment.