fix(update-notifier): resolve __dirname error on npx execution (#1406)

This commit is contained in:
matt korwel 2025-06-24 17:26:50 -07:00 committed by GitHub
parent 2505af8522
commit fbd8725c07
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 6 deletions

View File

@ -5,17 +5,14 @@
*/ */
import updateNotifier from 'update-notifier'; import updateNotifier from 'update-notifier';
import { readPackageUp } from 'read-package-up'; import { getPackageJson } from '../../utils/package.js';
export async function checkForUpdates(): Promise<string | null> { export async function checkForUpdates(): Promise<string | null> {
try { try {
// read-package-up looks for the closest package.json from cwd const packageJson = await getPackageJson();
const pkgResult = await readPackageUp({ cwd: __dirname }); if (!packageJson || !packageJson.name || !packageJson.version) {
if (!pkgResult) {
return null; return null;
} }
const { packageJson } = pkgResult;
const notifier = updateNotifier({ const notifier = updateNotifier({
pkg: { pkg: {
name: packageJson.name, name: packageJson.name,