scaffold/internal/project/local.go

38 lines
651 B
Go
Raw Normal View History

2020-02-20 08:31:22 +01:00
package project
import (
"net/url"
"strings"
"gopkg.in/src-d/go-billy.v4"
)
const LocalScheme = "local"
const FileScheme = "file"
type LocalFetcher struct{}
func (f *LocalFetcher) Fetch(url *url.URL) (billy.Filesystem, error) {
return nil, nil
}
func (f *LocalFetcher) Match(url *url.URL) bool {
if url.Scheme == LocalScheme || url.Scheme == FileScheme {
return true
}
2020-04-07 08:43:18 +02:00
if url.Scheme == "" && isFilesystemPath(url.Path) {
return true
}
return false
2020-02-20 08:31:22 +01:00
}
func NewLocalFetcher() *LocalFetcher {
return &LocalFetcher{}
}
func isFilesystemPath(path string) bool {
2020-04-07 08:43:18 +02:00
return strings.HasPrefix(path, ".") || strings.HasPrefix(path, "/")
2020-02-20 08:31:22 +01:00
}