Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jamo committed Jul 21, 2020
1 parent e1b1590 commit c4e1423
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/gatsby-telemetry/src/repository-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,14 @@ function getRepositoryFromHerokuEnv(): IRepositoryId | null {
return null
}

// Parse repository metadata from /proc/*/environ. This is a naive glob approach to only
// look pids in procfs.
const proc = readdirSync(`/proc`).filter(dir => Number.isFinite(Number(dir)))
const len = proc.length
for (let i = 0; i < len; i++) {
const dir = proc[i]
try {
// Piggyback on internal datastructures for control processes to see the git repo info
const environData = readFileSync(path.join(`/proc`, dir, `environ`))
?.toString(`utf8`)
?.split(/\0/)
Expand Down

0 comments on commit c4e1423

Please sign in to comment.