Skip to content

Commit

Permalink
fix(gatsby-telemetry): Read installedGatsbyVersion correctly for work…
Browse files Browse the repository at this point in the history
…spaces (#31196)

* Read Gatsby version correctly

* Simplify logic

Co-authored-by: Jarmo Isotalo <[email protected]>
(cherry picked from commit af12b66)
  • Loading branch information
sidharthachatterjee authored and vladar committed May 4, 2021
1 parent 1861243 commit 902dc8b
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions packages/gatsby-telemetry/src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,10 @@ export class AnalyticsTracker {
}

getGatsbyVersion(): SemVer {
const packageInfo = require(join(
process.cwd(),
`node_modules`,
`gatsby`,
`package.json`
))
try {
return packageInfo.version
const packageJson = require.resolve(`gatsby/package.json`)
const { version } = JSON.parse(fs.readFileSync(packageJson, `utf-8`))
return version
} catch (e) {
// ignore
}
Expand Down

0 comments on commit 902dc8b

Please sign in to comment.