Skip to content

Commit

Permalink
优化读取文件方式,并更新相关配置
Browse files Browse the repository at this point in the history
  • Loading branch information
scgm0 committed Jul 16, 2024
1 parent 267e8bf commit 2fbc5bd
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ options:
}

async function csv2pot(csv_path: string, po: boolean = true, add: string): Promise<void> {
const file = await Deno.open(csv_path);
using file = await Deno.open(csv_path);
const po_obj: {
[key: string]: string
} = {};
let pot_text: string = 'msgid ""\nmsgstr ""\n';

for await (const obj of readCSVObjects(file, {
lineSeparator: "\r\n",
lineSeparator: (await Deno.readTextFile(csv_path)).includes("\r") ? "\r\n" : "\n",
columnSeparator: args.s ?? ","
})) {
if (add === "true") {
Expand Down Expand Up @@ -64,7 +64,6 @@ msgstr ""
}
}

file.close();
const pot_path: string = `${dirname(csv_path)}/${basename(csv_path, ".csv")}.pot`;
await Deno.writeTextFile(pot_path, pot_text);
console.log(`已创建 ${pot_path}`);
Expand Down

0 comments on commit 2fbc5bd

Please sign in to comment.