fix import

This commit is contained in:
49lf
2024-10-12 00:58:33 -04:00
parent 71f7124913
commit 0b5cad701f
5 changed files with 9 additions and 8 deletions

View File

@ -140,7 +140,7 @@ const FileTreeItem = ({
async (eventType, path) => {
// Don't try to read a file that was removed.
if (isCurrentFile && eventType !== 'unlink') {
let code = await window.electron.readFile(path)
let code = await window.electron.readFile(path, 'utf-8')
code = normalizeLineEndings(code)
codeManager.updateCodeStateEditor(code)
}

View File

@ -28,8 +28,9 @@ class FileSystemManager {
)
}
return this.join(this.dir, path).then((filePath) => {
return window.electron.readFile(filePath)
return this.join(this.dir, path).then(async (filePath) => {
const content = await window.electron.readFile(filePath)
return content
})
}

View File

@ -448,7 +448,7 @@ export const readProjectSettingsFile = async (
}
}
const configToml = await window.electron.readFile(settingsPath)
const configToml = await window.electron.readFile(settingsPath, 'utf-8')
const configObj = parseProjectSettings(configToml)
if (err(configObj)) {
return Promise.reject(configObj)
@ -467,7 +467,7 @@ export const readAppSettingsFile = async () => {
// The file exists, read it and parse it.
if (window.electron.exists(settingsPath)) {
const configToml = await window.electron.readFile(settingsPath)
const configToml = await window.electron.readFile(settingsPath, 'utf-8')
const parsedAppConfig = parseAppSettings(configToml)
if (err(parsedAppConfig)) {
return Promise.reject(parsedAppConfig)
@ -527,7 +527,7 @@ export const readTokenFile = async () => {
let settingsPath = await getTokenFilePath()
if (window.electron.exists(settingsPath)) {
const token: string = await window.electron.readFile(settingsPath)
const token: string = await window.electron.readFile(settingsPath, 'utf-8')
if (!token) return ''
return token

View File

@ -109,7 +109,7 @@ export const fileLoader: LoaderFunction = async (
)
}
code = await window.electron.readFile(currentFilePath)
code = await window.electron.readFile(currentFilePath, 'utf-8')
code = normalizeLineEndings(code)
// Update both the state and the editor's code.

View File

@ -73,7 +73,7 @@ const watchFileOff = (path: string, key: string) => {
fsWatchListeners.set(path, watchers)
}
}
const readFile = (path: string) => fs.readFile(path, 'utf-8')
const readFile = (path: string, as?: string) => fs.readFile(path, as)
// It seems like from the node source code this does not actually block but also
// don't trust me on that (jess).
const exists = (path: string) => fsSync.existsSync(path)