Skip to content

Commit c8b9b7c

Browse files
GatsbyJS Botsidharthachatterjee
GatsbyJS Bot
andauthoredMay 4, 2021
fix(gatsby-telemetry): Read installedGatsbyVersion correctly for workspaces (#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>
1 parent 08cc344 commit c8b9b7c

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed
 

‎packages/gatsby-telemetry/src/telemetry.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,10 @@ export class AnalyticsTracker {
215215
}
216216

217217
getGatsbyVersion(): SemVer {
218-
const packageInfo = require(join(
219-
process.cwd(),
220-
`node_modules`,
221-
`gatsby`,
222-
`package.json`
223-
))
224218
try {
225-
return packageInfo.version
219+
const packageJson = require.resolve(`gatsby/package.json`)
220+
const { version } = JSON.parse(fs.readFileSync(packageJson, `utf-8`))
221+
return version
226222
} catch (e) {
227223
// ignore
228224
}

0 commit comments

Comments
 (0)
Please sign in to comment.