move store in local storage

This commit is contained in:
Thomas Ruoff
2021-03-10 23:53:35 +01:00
parent eaba68a779
commit 1633fad10b
13 changed files with 5414 additions and 193 deletions

View File

@@ -1,7 +1,6 @@
import { promisify } from 'util'
import { promises } from 'fs'
import { exec } from 'child_process'
import { v1 as uuidv1 } from 'uuid'
import { getDirPath, getDocPath, getTexCmd } from './utils'
const execPromise = promisify(exec)
@@ -10,7 +9,12 @@ async function copyToTemp(id: string, texDocument: string): Promise<void> {
const dirPath = getDirPath(id)
const docPath = getDocPath(id)
await promises.mkdir(dirPath)
try {
await promises.access(dirPath)
} catch (_) {
// well, seems it does not exists, let's create it
await promises.mkdir(dirPath)
}
await promises.writeFile(docPath, texDocument)
}
@@ -27,8 +31,7 @@ async function generateDoc(id: string): Promise<void> {
}
}
export default async function (texDocument: string) {
const id = uuidv1()
export default async function (id: string, texDocument: string) {
await copyToTemp(id, texDocument)
await generateDoc(id)
return id