@@ -47,12 +47,19 @@ func requireNPM(t *testing.T) {
4747 }
4848}
4949
50- func TestUpdateNPMLocalInstall (t * testing.T ) {
50+ func TestUpdateNPMInstall (t * testing.T ) {
5151 requireNPM (t )
5252
53+ // Skip if lstk is already installed globally (e.g., via Homebrew).
54+ // npm install -g fails with EEXIST when it tries to create a symlink
55+ // over an existing binary at the same path.
56+ if path , err := exec .LookPath ("lstk" ); err == nil {
57+ t .Skipf ("lstk already installed at %s, would conflict with npm install -g" , path )
58+ }
59+
5360 ctx := testContext (t )
5461
55- // Set up a fake local npm project.
62+ // Set up a fake local npm project so we get a binary inside node_modules .
5663 // On Windows, t.TempDir() may return a short 8.3 path (e.g. RUNNER~1)
5764 // while the program resolves the long path. EvalSymlinks normalizes both.
5865 projectDir , err := filepath .EvalSymlinks (t .TempDir ())
@@ -93,16 +100,16 @@ func TestUpdateNPMLocalInstall(t *testing.T) {
93100 out , err = buildCmd .CombinedOutput ()
94101 require .NoError (t , err , "go build failed: %s" , string (out ))
95102
96- // Run the binary directly (not through npx) so os.Executable() resolves to the node_modules path
103+ // Run the binary directly (not through npx) so os.Executable() resolves to the node_modules path.
104+ // The update should always use `npm install -g` regardless of local/global context.
97105 cmd := exec .CommandContext (ctx , nmBinaryPath , "update" , "--non-interactive" )
98106 cmd .Dir = projectDir
99107 stdout , err := cmd .CombinedOutput ()
100108 stdoutStr := string (stdout )
101109
102110 require .NoError (t , err , "lstk update failed: %s" , stdoutStr )
103111 requireExitCode (t , 0 , err )
104- assert .Contains (t , stdoutStr , "npm (local)" , "should detect local npm install" )
105- assert .Contains (t , stdoutStr , projectDir , "should show the project directory" )
112+ assert .Contains (t , stdoutStr , "npm install -g" , "should always use global install" )
106113 assert .Contains (t , stdoutStr , "Updated to" , "should complete the update" )
107114}
108115
0 commit comments