Skip to content

Commit

Permalink
refactor: format
Browse files Browse the repository at this point in the history
  • Loading branch information
jersou committed Oct 12, 2024
1 parent a7d2db2 commit 6f54fcf
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions serialize/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,27 @@ export async function folderToPack(
],
},
},
...((otherMetadata && Object.keys(otherMetadata).length > 0)
...(otherMetadata && Object.keys(otherMetadata).length > 0
? { extraMetadata: otherMetadata }
: {}),
};

if (folder.path) {
try {
if (audio) {
res.entrypoint.audioTimestamp = Deno.statSync(folder.path + "/" + audio)
.mtime
?.getTime();
res.entrypoint.audioTimestamp = Deno.statSync(
folder.path + "/" + audio,
).mtime?.getTime();
}
if (image) {
res.entrypoint.imageTimestamp = Deno.statSync(folder.path + "/" + image)
.mtime
?.getTime();
res.entrypoint.imageTimestamp = Deno.statSync(
folder.path + "/" + image,
).mtime?.getTime();
}
if (folder.path) {
res.entrypoint.pathTimestamp = Deno.statSync(folder.path).mtime
?.getTime();
res.entrypoint.pathTimestamp = Deno.statSync(
folder.path,
).mtime?.getTime();
}
} catch (_) {
//
Expand Down Expand Up @@ -112,17 +113,19 @@ export async function folderToMenu(
okTransition: {
class: "ActionNode",
name: folder.name,
options: (await Promise.all(folder.files
.map(async (f) =>
isFolder(f)
? await folderToMenu(f as Folder, path + "/" + f.name)
: isStory(f as File)
? await fileToStoryItem(f as File, folder)
: isZipFile(f as File)
? fileToZipMenu(`${path}/${folder.name}/${f.name}`)
: null
)))
.filter((f) => f) as (Menu | ZipMenu | StoryItem)[],
options: (
await Promise.all(
folder.files.map(async (f) =>
isFolder(f)
? await folderToMenu(f as Folder, path + "/" + f.name)
: isStory(f as File)
? await fileToStoryItem(f as File, folder)
: isZipFile(f as File)
? fileToZipMenu(`${path}/${folder.name}/${f.name}`)
: null
),
)
).filter((f) => f) as (Menu | ZipMenu | StoryItem)[],
},
};
return res;
Expand Down

0 comments on commit 6f54fcf

Please sign in to comment.