mirror of
https://github.com/tomru/pdfer.git
synced 2026-03-03 06:27:19 +01:00
move store in local storage
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user