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 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,
|
||||||
|
|
Loading…
Reference in New Issue