write modinfo.json after installing mod

This commit is contained in:
SpikeHD
2022-07-24 20:03:16 -07:00
parent 5077c19fdc
commit 552d612e7c
6 changed files with 84 additions and 36 deletions

View File

@@ -1,16 +1,24 @@
import { invoke } from '@tauri-apps/api'
import { listen } from '@tauri-apps/api/event'
export function unzip(file: string, dest: string, topLevelStrip?: boolean, onFinish?: () => void) {
invoke('unzip', {
zipfile: file,
destpath: dest,
topLevelStrip,
})
interface UnzipPayload {
file: string
new_folder: string
}
listen('extract_end', ({ payload }) => {
if (payload === file && onFinish) {
onFinish()
}
export function unzip(file: string, dest: string, topLevelStrip?: boolean): Promise<UnzipPayload> {
return new Promise((resolve) => {
invoke('unzip', {
zipfile: file,
destpath: dest,
topLevelStrip,
})
listen('extract_end', ({ payload }) => {
// @ts-expect-error Payload is an object
if (payload?.file === file) {
resolve(payload as UnzipPayload)
}
})
})
}