-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9751968
commit cdb78b0
Showing
8 changed files
with
41 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,31 @@ | ||
import { fileURLToPath } from "node:url" | ||
import { join } from "node:path" | ||
import { ensureDir } from "fs-extra" | ||
import { type Target, targets } from "@/types" | ||
|
||
// 在 esm 中 import.meta.url 应该是模块文件原始的位置,比较方便用于定位。 | ||
export const projectDir = fileURLToPath(new URL("..", import.meta.url)) | ||
export const databaseDir = join(projectDir, "database") | ||
export const exportedDir = join(projectDir, "exported") | ||
|
||
export async function ensureExportedFolder() { | ||
await ensureDir(exportedDir) | ||
return { | ||
path: exportedDir, | ||
status: true, | ||
} | ||
} | ||
|
||
export async function ensureTargetFolders(folder: string) { | ||
const folders: Record<Target, string> = { | ||
word: "", | ||
list: "", | ||
translation: "", | ||
} | ||
for (const target of targets) { | ||
folders[target] = join(exportedDir, folder, target) | ||
await ensureDir(folders[target]) | ||
} | ||
|
||
return folders | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters