fix(update-notifier): resolve __dirname error on npx execution (#1406)
This commit is contained in:
parent
2505af8522
commit
fbd8725c07
|
@ -5,17 +5,14 @@
|
|||
*/
|
||||
|
||||
import updateNotifier from 'update-notifier';
|
||||
import { readPackageUp } from 'read-package-up';
|
||||
import { getPackageJson } from '../../utils/package.js';
|
||||
|
||||
export async function checkForUpdates(): Promise<string | null> {
|
||||
try {
|
||||
// read-package-up looks for the closest package.json from cwd
|
||||
const pkgResult = await readPackageUp({ cwd: __dirname });
|
||||
if (!pkgResult) {
|
||||
const packageJson = await getPackageJson();
|
||||
if (!packageJson || !packageJson.name || !packageJson.version) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { packageJson } = pkgResult;
|
||||
const notifier = updateNotifier({
|
||||
pkg: {
|
||||
name: packageJson.name,
|
||||
|
|
Loading…
Reference in New Issue