File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
packages/shared/src/functions Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 1+ import path from 'node:path'
2+ import { fileURLToPath } from 'node:url'
13import { log } from '@clack/prompts'
2- import isGlobal from 'is-installed-globally'
34import { addDependency } from 'nypm'
45import { i18n } from '../i18n'
56
7+ function isInstalledLocally ( ) : boolean {
8+ // Check if CLI is inside a local node_modules (relative to cwd)
9+ // If so, it's a local installation and shouldn't be upgraded globally
10+ const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
11+ const cwd = process . cwd ( )
12+ const localNodeModules = path . join ( cwd , 'node_modules' )
13+
14+ return __dirname . startsWith ( localNodeModules )
15+ }
16+
617export async function upgradeSelf ( pkgName : string ) {
7- if ( ! isGlobal ) {
18+ if ( isInstalledLocally ( ) ) {
819 log . warning ( i18n . t ( 'commands.upgrade.not_global' , { pkg : pkgName } ) )
920 return
1021 }
You can’t perform that action at this time.
0 commit comments