forked from markbates/pkger
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request markbates#50 from markbates/here-here
use gobuffalo/here fixes markbates#49
- Loading branch information
Showing
53 changed files
with
82 additions
and
649 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,4 @@ | ||
# These are supported funding model platforms | ||
|
||
github: markbates | ||
patreon: buffalo |
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,49 +1,13 @@ | ||
package here | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"os/exec" | ||
"regexp" | ||
"strings" | ||
"sync" | ||
"github.com/gobuffalo/here" | ||
) | ||
|
||
var cache = &infoMap{ | ||
data: &sync.Map{}, | ||
} | ||
type Info = here.Info | ||
type Module = here.Module | ||
type Path = here.Path | ||
|
||
func run(n string, args ...string) ([]byte, error) { | ||
c := exec.Command(n, args...) | ||
|
||
bb := &bytes.Buffer{} | ||
c.Stdout = bb | ||
c.Stderr = bb | ||
err := c.Run() | ||
if err != nil { | ||
return nil, fmt.Errorf("%w: %q: %s", err, strings.Join(c.Args, " "), bb) | ||
} | ||
|
||
return bb.Bytes(), nil | ||
} | ||
|
||
func Cache(p string, fn func(string) (Info, error)) (Info, error) { | ||
i, ok := cache.Load(p) | ||
if ok { | ||
return i, nil | ||
} | ||
i, err := fn(p) | ||
if err != nil { | ||
return i, err | ||
} | ||
cache.Store(p, i) | ||
return i, nil | ||
} | ||
|
||
func ClearCache() { | ||
cache = &infoMap{ | ||
data: &sync.Map{}, | ||
} | ||
} | ||
|
||
var nonGoDirRx = regexp.MustCompile(`cannot find main|go help modules|go: |build .:|no Go files|can't load package`) | ||
var Dir = here.Dir | ||
var Package = here.Package | ||
var Current = here.Current |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.