diff --git a/main.go b/main.go index 5e4a5b8..1d25500 100644 --- a/main.go +++ b/main.go @@ -43,7 +43,7 @@ func main() { func scan(c *cli.Context) error { directory := c.Args().First() - fmt.Println(strings.Join(getAllManifests(directory), ", ")) + fmt.Println(strings.Join(getListOfManifestFilenames(directory), ", ")) // TODO, actually scan, don't just print names return nil } diff --git a/manifests.go b/manifests.go index 43ac30a..761fd07 100644 --- a/manifests.go +++ b/manifests.go @@ -10,7 +10,6 @@ import ( /* When adding new manifest types, for new package managers add a new entry here. - */ func manifestGlobs() []string { @@ -112,12 +111,12 @@ func manifestGlobs() []string { return globs } -func getAllManifests(directory string) []string { +func getListOfManifestFilenames(directory string) []string { matchingFiles := make([]string, 0) for _, glob := range manifestGlobs() { pathGlob := fmt.Sprintf("%s/**/%s", directory, glob) - files := getManifestGlobMatches(pathGlob) + files := getListOfGlobMatches(pathGlob) if len(files) > 0 { matchingFiles = append(matchingFiles, files...) @@ -126,7 +125,7 @@ func getAllManifests(directory string) []string { return matchingFiles } -func getManifestGlobMatches(glob string) []string { +func getListOfGlobMatches(glob string) []string { files, err := doublestar.Glob(glob) if err != nil { log.Fatal(err) diff --git a/manifests_test.go b/manifests_test.go index 6e826b0..c9e82af 100644 --- a/manifests_test.go +++ b/manifests_test.go @@ -7,31 +7,30 @@ import ( "github.com/stretchr/testify/assert" ) -func TestGetManifestGlobMatches(t *testing.T) { +func TestGetListOfGlobMatches(t *testing.T) { //assert getManifestMatches gets all requirements.txt expected := []string{ "test/fixtures/subdir/requirements.txt", "test/fixtures/a/b/c/d/e/f/g/requirements.txt", } - got := getManifestGlobMatches("test/**/requirements.txt") + got := getListOfGlobMatches("test/**/requirements.txt") sort.Strings(expected) sort.Strings(got) assert.Equal(t, expected, got, "they should be equal") } -func TestGetAllManifests(t *testing.T) { +func TestGetListOfManifestFilenames(t *testing.T) { expected := []string{ "test/fixtures/yarn.lock", "test/fixtures/Gemfile", "test/fixtures/a/b/c/d/e/f/g/requirements.txt", "test/fixtures/subdir/requirements.txt", } - got := getAllManifests("test/") + got := getListOfManifestFilenames("test/") sort.Strings(expected) sort.Strings(got) assert.Equal(t, expected, got, "they should match") - }