magex

package module
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2022 License: MIT Imports: 0 Imported by: 0

README

Magefile Extensions

test

This library provides helper methods to use with mage.

Below is a sample of the type of helpers available. Full examples and documentation is on godoc.

// +build mage

package main

import (
	"github.com/carolynvs/magex/pkg"
	"github.com/carolynvs/magex/shx"
)

// Check if packr2 is in the bin/ directory and is at least v2.
// If not, install packr@v2.8.0 into bin/
func EnsurePackr2() error {
	opts := pkg.EnsurePackageOptions{
		Name: "github.com/gobuffalo/packr/v2/packr2",
		DefaultVersion: "v2.8.0",
		VersionCommand: "version",
		Destination: "bin",
    }
   return pkg.EnsurePackageWith(opts)
}

// Install mage if it's not available, and ensure it's in PATH. We don't care which version
func Mage() error {
    return pkg.EnsureMage("")
}

// Run a docker registry in a container. Do not print stdout and only print
// stderr when the command fails even when -v is set.
//
// Useful for commands that you only care about when it fails, keeping unhelpful
// output out of your logs.
func StartRegistry() error {
    return shx.RunE("docker", "run", "-d", "-p", "5000:5000", "--name", "registry", "registry:2")
}

// Use go to download a tool, build and install it manually so 
// that it has version information embedded in the final binary.
func CustomInstallTool() error {
	err := shx.RunE("go", "get", "-u", "github.com/magefile/mage")
	if err != nil {
    		return err
	}
    
	src := filepath.Join(GOPATH(), "src/github.com/magefile/mage")
	return shx.Command("go", "run", "bootstrap.go").In(src).RunE()
}

Documentation

Overview

Package magex provides helper methods for working with Magefiles (https://magefile.org)

Directories

Path Synopsis
Package ci provides helpers for interacting with the underlying CI system.
Package ci provides helpers for interacting with the underlying CI system.
Package mgx provides helpers that complement the github.com/magefile/mage/mg package.
Package mgx provides helpers that complement the github.com/magefile/mage/mg package.
pkg
Helper methods for installing Go packages on any platform.
Helper methods for installing Go packages on any platform.
archive
Helper methods for working with archived/compressed files.
Helper methods for working with archived/compressed files.
Extend the github.com/magefile/mage/sh package with helper functions to run commands in a magefile.
Extend the github.com/magefile/mage/sh package with helper functions to run commands in a magefile.
Helper methods for supporting cross-platform shells.
Helper methods for supporting cross-platform shells.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL