diff --git a/src/bootstrap/migration.go b/src/bootstrap/migration.go index 5432280..d3f3502 100644 --- a/src/bootstrap/migration.go +++ b/src/bootstrap/migration.go @@ -27,6 +27,13 @@ var ( deleteScheduledTask = defaultScheduledTaskDelete ) +// RetireCommunityUserPayload removes the per-user community app payload and its +// HKCU uninstall/App Paths/shell registrations. Node installs and runtime dirs stay. +// No-op when this process is itself the LocalAppData community binary. +func RetireCommunityUserPayload(dataRoot string) error { + return cleanupLegacyUserPayload(dataRoot) +} + func cleanupLegacyUserPayload(dataRoot string) error { programRoot, err := ProgramRoot() if err != nil { diff --git a/src/cmd/main.go b/src/cmd/main.go index f872673..b8f8542 100644 --- a/src/cmd/main.go +++ b/src/cmd/main.go @@ -93,6 +93,24 @@ func main() { os.Exit(1) } return + case "--retire-community-payload": + // Impersonated MSI CA: drop community nvm.exe/utils/.icons and the HKCU + // uninstall entry during install, not on first nvm launch. + settings.Load() + dataRoot, err := bootstrap.DataRoot() + if err != nil || dataRoot == "" { + local := os.Getenv("LOCALAPPDATA") + if local == "" { + fmt.Fprint(os.Stderr, "LOCALAPPDATA is empty; cannot retire community payload\n") + os.Exit(1) + } + dataRoot = filepath.Join(local, "Author Software", "nvm") + } + if err := bootstrap.RetireCommunityUserPayload(dataRoot); err != nil { + fmt.Fprint(os.Stderr, err.Error()) + os.Exit(1) + } + return case "--register-installed-versions": // Invoked by the installer after migration to ensure all migrated // versions are registered in Windows Apps the same way normal installs are.