Skip to content

Commit

Permalink
fix: handle relative paths in convert plugin (#34)
Browse files Browse the repository at this point in the history
* fix: handle relative paths in convert plugin

* fix: update dist
  • Loading branch information
ojeytonwilliams authored Apr 15, 2024
1 parent 6fc59b1 commit e0e2a30
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 7 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40287,15 +40287,16 @@ const getFiles = (directory, fileList = []) => __awaiter(void 0, void 0, void 0,
/**
* Module to convert Simplified Chinese files to Traditional Chinese.
*
* @param {string[]} directories The directory to convert.
* @param {string[]} paths The directories and file paths to convert.
*/
const convertChinese = (directories) => __awaiter(void 0, void 0, void 0, function* () {
const convertChinese = (paths) => __awaiter(void 0, void 0, void 0, function* () {
console.info("Getting file list...");
for (const directory of directories) {
const status = yield (0, promises_1.stat)(directory);
for (const relativePath of paths) {
const absolutePath = (0, path_1.join)(process.cwd(), relativePath);
const status = yield (0, promises_1.stat)(absolutePath);
const files = status.isDirectory()
? yield getFiles((0, path_1.join)(process.cwd(), directory))
: [directory];
? yield getFiles(absolutePath)
: [absolutePath];
for (const file of files) {
console.info(`Converting ${file}...`);
const fileText = yield (0, promises_1.readFile)(file, "utf-8");
Expand Down
13 changes: 7 additions & 6 deletions src/plugins/convert-chinese.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ const getFiles = async (directory: string, fileList: string[] = []) => {
/**
* Module to convert Simplified Chinese files to Traditional Chinese.
*
* @param {string[]} directories The directory to convert.
* @param {string[]} paths The directories and file paths to convert.
*/
export const convertChinese = async (directories: string[]) => {
export const convertChinese = async (paths: string[]) => {
console.info("Getting file list...");
for (const directory of directories) {
const status = await stat(directory);
for (const relativePath of paths) {
const absolutePath = join(process.cwd(), relativePath);
const status = await stat(absolutePath);
const files = status.isDirectory()
? await getFiles(join(process.cwd(), directory))
: [directory];
? await getFiles(absolutePath)
: [absolutePath];
for (const file of files) {
console.info(`Converting ${file}...`);
const fileText = await readFile(file, "utf-8");
Expand Down

0 comments on commit e0e2a30

Please sign in to comment.