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 <jamo@isotalo.fi>
  • Loading branch information
sidharthachatterjee and jamo committed May 4, 2021
1 parent c94fadd commit af12b66
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 af12b66

Please sign in to comment.