Skip to content

Commit

Permalink
feat: support single file paths for chinese plugin (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
Naomi authored Apr 10, 2024
1 parent c813542 commit 6fc59b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40292,7 +40292,10 @@ const getFiles = (directory, fileList = []) => __awaiter(void 0, void 0, void 0,
const convertChinese = (directories) => __awaiter(void 0, void 0, void 0, function* () {
console.info("Getting file list...");
for (const directory of directories) {
const files = yield getFiles((0, path_1.join)(process.cwd(), directory));
const status = yield (0, promises_1.stat)(directory);
const files = status.isDirectory()
? yield getFiles((0, path_1.join)(process.cwd(), directory))
: [directory];
for (const file of files) {
console.info(`Converting ${file}...`);
const fileText = yield (0, promises_1.readFile)(file, "utf-8");
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/convert-chinese.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ const getFiles = async (directory: string, fileList: string[] = []) => {
export const convertChinese = async (directories: string[]) => {
console.info("Getting file list...");
for (const directory of directories) {
const files = await getFiles(join(process.cwd(), directory));
const status = await stat(directory);
const files = status.isDirectory()
? await getFiles(join(process.cwd(), directory))
: [directory];
for (const file of files) {
console.info(`Converting ${file}...`);
const fileText = await readFile(file, "utf-8");
Expand Down

0 comments on commit 6fc59b1

Please sign in to comment.