UNPKG

@sentry/nextjs

Version:
35 lines (29 loc) 842 B
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const fs = require('fs'); const resolve = require('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 resolve.sync('next/package.json', { basedir: process.cwd() }); } catch { return undefined; } } exports.getNextjsVersion = getNextjsVersion; //# sourceMappingURL=util.js.map