Skip to content

Commit d856e95

Browse files
authored
Fix root path config resolve (#206)
fix: #196
1 parent 1258d40 commit d856e95

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/server/src/SettingStore.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as fs from 'fs'
2+
import * as path from 'path'
23
import EventEmitter from 'events'
34
import log4js from 'log4js'
45

@@ -40,9 +41,9 @@ type PersonalConfig = {
4041
connections: Connection[]
4142
}
4243

43-
function fileExists(path: string) {
44+
function fileExists(filePath: string) {
4445
try {
45-
return fs.statSync(path).isFile()
46+
return fs.statSync(path.resolve(filePath)).isFile()
4647
} catch (e) {
4748
const err = e as NodeJS.ErrnoException
4849
if (err && err.code === 'ENOENT') {
@@ -53,7 +54,7 @@ function fileExists(path: string) {
5354
}
5455

5556
function readFile(filePath: string) {
56-
return fs.readFileSync(filePath, 'utf8').replace(/^\ufeff/u, '')
57+
return fs.readFileSync(path.resolve(filePath), 'utf8').replace(/^\ufeff/u, '')
5758
}
5859

5960
export default class SettingStore extends EventEmitter.EventEmitter {

0 commit comments

Comments
 (0)