Skip to content

Commit

Permalink
Add fallback to usage info check
Browse files Browse the repository at this point in the history
  • Loading branch information
pmmmwh authored and n4bb12 committed Nov 22, 2019
1 parent 124920e commit 12113bd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/client/verdaccio-4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,17 @@ function modifyUsageInfoNodes() {
const loggedIn = isLoggedIn()

const infoElements = document.querySelectorAll(usageInfoSelector)
const cachedParent = Array.prototype.find.call(infoElements, node => node.innerText.match(
const firstUsageInfoEl = Array.prototype.find.call(infoElements, node => node.innerText.match(
// This checks for an element showing instructions to set the registry URL
/((npm|pnpm) set|(yarn) config set)/,
)).parentElement as HTMLDivElement
))

// We can't find any element related to usage instructions
if (!firstUsageInfoEl) {
return
}

const cachedParent = firstUsageInfoEl.parentElement as HTMLDivElement

infoElements.forEach((node => {
const infoEl = node as HTMLSpanElement
Expand Down

0 comments on commit 12113bd

Please sign in to comment.