fix(init): ensure shims call namespaced which command
This commit is contained in:
parent
4b6a996e1d
commit
1b87b6fa1e
2 changed files with 30 additions and 1 deletions
|
@ -21,7 +21,7 @@ var SHIMS = []string{
|
|||
const DEFAULT_PERMISSION = 0775
|
||||
|
||||
func writeShim(shimPath string) error {
|
||||
shimContent := []byte("#!/bin/bash\n$(v which --raw) $@")
|
||||
shimContent := []byte("#!/bin/bash\n$(v python which --raw) $@")
|
||||
if err := os.WriteFile(shimPath, shimContent, DEFAULT_PERMISSION); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
29
commands_test.go
Normal file
29
commands_test.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
state "v/state"
|
||||
testutils "v/testutils"
|
||||
)
|
||||
|
||||
func TestWriteShim(t *testing.T) {
|
||||
defer testutils.SetupAndCleanupEnvironment(t)()
|
||||
|
||||
os.Mkdir(state.GetStatePath("shims"), 0775)
|
||||
testShimPath := state.GetStatePath("shims", "testshim")
|
||||
e := writeShim(testShimPath)
|
||||
|
||||
shimContent, _ := ioutil.ReadFile(testShimPath)
|
||||
|
||||
if e != nil {
|
||||
t.Errorf("Errored while writing shim")
|
||||
}
|
||||
|
||||
if !strings.Contains(string(shimContent), "$(v python which --raw) $@") {
|
||||
t.Errorf("Expected shim to contain pass-through via 'which', got %s", shimContent)
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue