jan/electron/utils/path.ts
NamH 4cf47777e6
feat: allow user to move jan folder (#1649)
* feat: allow user to move jan folder

Signed-off-by: James <james@jan.ai>

---------

Signed-off-by: James <james@jan.ai>
Co-authored-by: James <james@jan.ai>
Co-authored-by: Louis <louis@jan.ai>
2024-01-22 14:37:46 +07:00

29 lines
734 B
TypeScript

import { join } from 'path'
import { app } from 'electron'
import { mkdir } from 'fs-extra'
import { existsSync } from 'fs'
import { getJanDataFolderPath } from '@janhq/core/node'
export async function createUserSpace(): Promise<void> {
const janDataFolderPath = getJanDataFolderPath()
if (!existsSync(janDataFolderPath)) {
try {
await mkdir(janDataFolderPath)
} catch (err) {
console.error(
`Unable to create Jan data folder at ${janDataFolderPath}: ${err}`
)
}
}
}
export function getResourcePath() {
let appPath = join(app.getAppPath(), '..', 'app.asar.unpacked')
if (!app.isPackaged) {
// for development mode
appPath = join(__dirname, '..', '..')
}
return appPath
}