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

27 lines
729 B
TypeScript

import { ipcMain } from 'electron'
import { FileSystemRoute } from '@janhq/core'
import { join } from 'path'
import { getJanDataFolderPath, normalizeFilePath } from '@janhq/core/node'
/**
* Handles file system operations.
*/
export function handleFsIPCs() {
const moduleName = 'fs'
Object.values(FileSystemRoute).forEach((route) => {
ipcMain.handle(route, async (event, ...args) => {
return import(moduleName).then((mdl) =>
mdl[route](
...args.map((arg) =>
typeof arg === 'string' &&
(arg.includes(`file:/`) || arg.includes(`file:\\`))
? join(getJanDataFolderPath(), normalizeFilePath(arg))
: arg
)
)
)
})
})
}