mirror of
https://github.com/logos-storage/codex-factory.git
synced 2026-01-02 13:03:07 +00:00
fix: proper error handling when conf does not exists (#106)
This commit is contained in:
parent
97ad7c80d9
commit
c1a1d3a885
@ -16,16 +16,26 @@ export function stripCommit(version: string): string {
|
||||
|
||||
async function searchPackageJson(): Promise<string | undefined> {
|
||||
const expectedPath = path.join(process.cwd(), 'package.json')
|
||||
const pkgJson = JSON.parse(await readFile(expectedPath, { encoding: 'utf8' }))
|
||||
|
||||
return pkgJson?.engines?.bee
|
||||
try {
|
||||
const pkgJson = JSON.parse(await readFile(expectedPath, { encoding: 'utf8' }))
|
||||
|
||||
return pkgJson?.engines?.bee
|
||||
} catch (e) {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
async function searchBeeFactory(): Promise<string | undefined> {
|
||||
const expectedPath = path.join(process.cwd(), '.beefactory.json')
|
||||
const pkgJson = JSON.parse(await readFile(expectedPath, { encoding: 'utf8' }))
|
||||
|
||||
return pkgJson?.version
|
||||
try {
|
||||
const pkgJson = JSON.parse(await readFile(expectedPath, { encoding: 'utf8' }))
|
||||
|
||||
return pkgJson?.version
|
||||
} catch (e) {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
export async function findBeeVersion(): Promise<string> {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user