* 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>
27 lines
729 B
TypeScript
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
|
|
)
|
|
)
|
|
)
|
|
})
|
|
})
|
|
}
|