UNPKG

@sentry/nextjs

Version:
33 lines (28 loc) 740 B
import * as fs from 'fs'; import { sync } from 'resolve'; /** * Returns the version of Next.js installed in the project, or undefined if it cannot be determined. */ function getNextjsVersion() { const nextjsPackageJsonPath = resolveNextjsPackageJson(); if (nextjsPackageJsonPath) { try { const nextjsPackageJson = JSON.parse( fs.readFileSync(nextjsPackageJsonPath, { encoding: 'utf-8' }), ); return nextjsPackageJson.version; } catch { // noop } } return undefined; } function resolveNextjsPackageJson() { try { return sync('next/package.json', { basedir: process.cwd() }); } catch { return undefined; } } export { getNextjsVersion }; //# sourceMappingURL=util.js.map