Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eleven-apples-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@slack/cli-hooks": patch
---

refactor(cli-hooks): use optional chaining check to gather project dependencies
2 changes: 1 addition & 1 deletion packages/cli-hooks/src/check-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ async function collectVersionInfo(packageName) {
async function getProjectPackageVersion(packageName) {
const stdout = await execWrapper(`npm list ${packageName} --depth=0 --json`);
const currentVersionOutput = JSON.parse(stdout);
if (!currentVersionOutput.dependencies || !currentVersionOutput.dependencies[packageName]) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👁️‍🗨️ thought: IMHO the chained pattern is confusing in this statement and might make later changes more difficult.

if (!currentVersionOutput.dependencies?.[packageName]) {
throw new Error(`Failed to gather project information about ${packageName}`);
}
return currentVersionOutput.dependencies[packageName].version;
Expand Down