mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 04:39:58 +00:00
api/load-from-fs: refactor loadFile, use in loadJSON
This commit is contained in:
parent
0e0ad7cb0e
commit
6d817f149e
1 changed files with 2 additions and 6 deletions
|
@ -9,16 +9,12 @@ const root = join(
|
||||||
|
|
||||||
export function loadJSON(path) {
|
export function loadJSON(path) {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(fs.readFileSync(join(root, path), 'utf-8'))
|
return JSON.parse(loadFile(path))
|
||||||
} catch {
|
} catch {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loadFile(path) {
|
export function loadFile(path) {
|
||||||
try {
|
return fs.readFileSync(join(root, path), 'utf-8')
|
||||||
return fs.readFileSync(path, 'utf-8')
|
|
||||||
} catch {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue