Commit 78f32a4
committed
Fix Windows auto-upgrade for local CLI installs
`currentProcessIsGlobal()` decides between global and local installs by
comparing the project root against `process.argv[1]`. The project root
flows through `getProjectDir` -> `findPathUpSync` -> `normalizePath` (pathe),
which always returns forward slashes on every platform. `process.argv[1]`
is OS-native, so on Windows it arrives backslash-separated and the raw
`startsWith` comparison ends up as:
binDir: C:\\Users\\me\\proj\\node_modules\\@Shopify\\cli\\bin\\run.js
projectDir: C:/Users/me/proj
binDir.startsWith(projectDir) => false
The local install was misclassified as global, so the postrun hook ran
`npm install -g @shopify/cli@latest` after every command on Windows even
when @shopify/cli was declared as a project dependency.
Switches the comparison to `isSubpath` (pathe.relative under the hood)
which tolerates either separator, and bails early if argv[1] is empty so
we don't accidentally classify it as 'in any directory'.
Adds a regression test that constructs the exact Windows shape (forward-
slash projectDir vs. backslash argv[1]) — the existing POSIX-shaped tests
happened to agree on slashes when CI runs on Linux, so they didn't catch
this.
Reported by Nick Wesselman; root cause analysis by River.1 parent 95e9788 commit 78f32a4
3 files changed
Lines changed: 33 additions & 3 deletions
File tree
- .changeset
- packages/cli-kit/src/public/node
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
84 | 101 | | |
85 | 102 | | |
86 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
30 | 33 | | |
31 | | - | |
32 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
33 | 41 | | |
34 | 42 | | |
35 | 43 | | |
| |||
0 commit comments