Skip to content

Commit

Permalink
chore: allow overriding of the lib install path
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Mar 14, 2021
1 parent 2dcdd40 commit f9d7d68
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ jobs:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Set Golang shared lib variable
run: echo '::set-env name=LD_LIBRARY_PATH::/tmp'

- name: Install Go
uses: actions/setup-go@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ install:
fi

installv3:
./build/pact-go_linux_amd64 -l DEBUG install
./build/pact-go_linux_amd64 -l DEBUG install --libDir /tmp

pact: install docker
@echo "--- 🔨 Running Pact examples"
Expand Down
10 changes: 9 additions & 1 deletion command/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/spf13/cobra"
)

var path string
var libDir = ""
var installCmd = &cobra.Command{
Use: "install",
Short: "Check required tools",
Expand All @@ -19,6 +19,13 @@ var installCmd = &cobra.Command{

// Run the installer
i, err := installer.NewInstaller()

//
if libDir != "" {
log.Println("[INFO] set lib dir target to", libDir)
i.SetLibDir(libDir)
}

if err != nil {
log.Println("[ERROR] Your Pact library installation is out of date and we were unable to download a newer one for you:", err)
os.Exit(1)
Expand All @@ -32,5 +39,6 @@ var installCmd = &cobra.Command{
}

func init() {
installCmd.Flags().StringVarP(&libDir, "libDir", "d", "", "Target directory to install the library")
RootCmd.AddCommand(installCmd)
}
5 changes: 5 additions & 0 deletions v3/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ func NewInstaller(opts ...installerConfig) (*Installer, error) {
return i, nil
}

// SetLibDir overrides the default library dir
func (i *Installer) SetLibDir(dir string) {
i.libDir = dir
}

// CheckInstallation checks installation of all of the required libraries
// and downloads if they aren't present
func (i *Installer) CheckInstallation() error {
Expand Down

0 comments on commit f9d7d68

Please sign in to comment.