-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve installation by storing lib metadata locally
- Loading branch information
Showing
8 changed files
with
264 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package command | ||
|
||
import ( | ||
"log" | ||
"os" | ||
|
||
"github.com/pact-foundation/pact-go/v2/installer" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var checkCmd = &cobra.Command{ | ||
Use: "check", | ||
Short: "Check required libraries", | ||
Long: "Check the correct version of required libraries", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
setLogLevel(verbose, logLevel) | ||
|
||
// Run the installer | ||
i, err := installer.NewInstaller() | ||
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) | ||
} | ||
|
||
if libDir != "" { | ||
log.Println("[INFO] set lib dir target to", libDir) | ||
i.SetLibDir(libDir) | ||
} | ||
|
||
if err = i.CheckPackageInstall(); err != nil { | ||
log.Println("[DEBUG] error from CheckPackageInstall:", err) | ||
log.Println("[ERROR] Your Pact library installation is out of date. Run `pact-go install` to correct") | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
checkCmd.Flags().StringVarP(&libDir, "libDir", "d", "", "Target directory of the library installation") | ||
RootCmd.AddCommand(checkCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.