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) (#31208)

* Read Gatsby version correctly

* Simplify logic

Co-authored-by: Jarmo Isotalo <jamo@isotalo.fi>
(cherry picked from commit af12b66)

Co-authored-by: Sidhartha Chatterjee <me@sidharthachatterjee.com>
  • Loading branch information
GatsbyJS Bot and sidharthachatterjee committed May 4, 2021
1 parent 08cc344 commit c8b9b7c
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions packages/gatsby-telemetry/src/telemetry.ts
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 c8b9b7c

Please sign in to comment.