Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
(omits-on-nil current/error), the table renderer (empty state,
mixed empty/error/success), and the `--manager` resolution
helper. Closes #45.
- `internal/cli/packages.go`: `runSnapshot` and `runRestore` now
pass `cmd.Context()` to `packages.Snapshot` / `packages.Restore`
(and to the `--from` branch via the same `ctx` local) instead of
`context.Background()`. Both are cobra `RunE` functions with a
live context available — using `context.Background()` meant
Ctrl-C during `nodeup packages snapshot` or `nodeup packages
restore` could not cancel the in-flight `npm ls -g` / `npm
install -g` subprocess, so the child process kept running after
the user aborted. The fix is the same contextcheck violation
`internal/cli/upgrade.go` and `check.go` already addressed as
part of #48 — `packages.go` was the last `RunE` file in the tree
still using `context.Background()`. The unused `"context"`
import is dropped. Closes #49.

## [0.0.0] - 2024-07-01

Expand Down
5 changes: 2 additions & 3 deletions internal/cli/packages.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cli

import (
"context"
"fmt"

"github.com/Masterminds/semver/v3"
Expand Down Expand Up @@ -52,7 +51,7 @@ func runSnapshot(cmd *cobra.Command, args []string) error {
return fmt.Errorf("get current version: %w", err)
}

if err := packages.Snapshot(context.Background(), m.Name(), version); err != nil {
if err := packages.Snapshot(cmd.Context(), m.Name(), version); err != nil {
return fmt.Errorf("snapshot failed: %w", err)
}

Expand Down Expand Up @@ -138,7 +137,7 @@ the "interrupted upgrade" warning).`,
}

func runRestore(cmd *cobra.Command, args []string) error {
ctx := context.Background()
ctx := cmd.Context()
fromPath, _ := cmd.Flags().GetString("from")

// runRestore doubles as the "replay the upgrade-in-progress sentinel"
Expand Down
Loading