refactor: migrate src/cli/cmd/import.ts from Bun.file() to Filesystem module (#14143)
This commit is contained in:
@@ -8,6 +8,7 @@ import { SessionTable, MessageTable, PartTable } from "../../session/session.sql
|
||||
import { Instance } from "../../project/instance"
|
||||
import { ShareNext } from "../../share/share-next"
|
||||
import { EOL } from "os"
|
||||
import { Filesystem } from "../../util/filesystem"
|
||||
|
||||
/** Discriminated union returned by the ShareNext API (GET /api/share/:id/data) */
|
||||
export type ShareData =
|
||||
@@ -116,8 +117,7 @@ export const ImportCommand = cmd({
|
||||
|
||||
exportData = transformed
|
||||
} else {
|
||||
const file = Bun.file(args.file)
|
||||
exportData = await file.json().catch(() => {})
|
||||
exportData = await Filesystem.readJson<NonNullable<typeof exportData>>(args.file).catch(() => undefined)
|
||||
if (!exportData) {
|
||||
process.stdout.write(`File not found: ${args.file}`)
|
||||
process.stdout.write(EOL)
|
||||
|
||||
Reference in New Issue
Block a user