Skip to content

Commit

Permalink
fix: do not throw when there is no package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
innocenzi committed Nov 8, 2024
1 parent 1792e2f commit 3900c4d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,15 @@ export async function loadHybridlyContext(extension: ExtensionContext): Promise<
return false
}

const pkg = JSON.parse(fs.readFileSync(path.resolve(extension.cwd, 'package.json'), { encoding: 'utf-8' }))
const deps = { ...pkg.dependencies, ...pkg.devDependencies }
if (!deps.hybridly) {
log.appendLine('Hybridly was not found in `package.json`.')
try {
const pkg = JSON.parse(fs.readFileSync(path.resolve(extension.cwd, 'package.json'), { encoding: 'utf-8' }))
const deps = { ...pkg.dependencies, ...pkg.devDependencies }
if (!deps.hybridly) {
log.appendLine('Hybridly was not found in `package.json`.')
return false
}
} catch (error) {
log.appendLine('Could not find `package.json`.')
return false
}

Expand Down

0 comments on commit 3900c4d

Please sign in to comment.