Skip to content

Commit

Permalink
Use tsx instead of ts-node
Browse files Browse the repository at this point in the history
  • Loading branch information
justinsilvestre committed Nov 24, 2024
1 parent 3782ac7 commit 491e138
Show file tree
Hide file tree
Showing 4 changed files with 443 additions and 133 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ node_modules
*.log.json

.DS_Store

.react-router
20 changes: 14 additions & 6 deletions app/lib/files.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,18 @@ export const files = {
};

function vendor<S extends string>(string: S) {
return path.resolve(__dirname, "vendor", string) as `${string}/vendor/${S}`;
return path.resolve(
import.meta.url,
"vendor",
string,
) as `${string}/vendor/${S}`;
}
function dic<S extends string>(string: S) {
return path.resolve(__dirname, "dic", string) as `${string}/vendor/${S}`;
return path.resolve(
import.meta.url,
"dic",
string,
) as `${string}/vendor/${S}`;
}

function readTextFileSync<T>(filepath: string) {
Expand All @@ -51,14 +59,14 @@ export function getKvgFilePath(character: string) {
.codePointAt(0)
?.toString(16)
.padStart(5, "0")}.svg`;
return path.resolve(__dirname, "vendor", "kanjivg", "svgs", filename);
return path.resolve(import.meta.url, "vendor", "kanjivg", "svgs", filename);
}

export function getGlyphwikiSvgFilePath(figureKey: string) {
const filename = `${
[...figureKey].length === 1 ? getGlyphWikiCode(figureKey) : figureKey
}.svg`;
return path.resolve(__dirname, "vendor", "glyphwiki", "svgs", filename);
return path.resolve(import.meta.url, "vendor", "glyphwiki", "svgs", filename);
}

export function getGlyphWikiCode(key: string) {
Expand All @@ -76,7 +84,7 @@ export function getGlyphWikiCode(key: string) {

export function getShuowenFilePath(filenameCharacters: string) {
return path.resolve(
__dirname,
import.meta.url,
"dic",
"shuowenSvgs",
Array.from(filenameCharacters, (char) =>
Expand All @@ -87,7 +95,7 @@ export function getShuowenFilePath(filenameCharacters: string) {

export function getGlyphsFilePath(char: string) {
return path.resolve(
__dirname,
import.meta.url,
"dic",
"glyphs",
char.codePointAt(0)!.toString(16) + ".json",
Expand Down
Loading

0 comments on commit 491e138

Please sign in to comment.