This commit is contained in:
Tyrel Souza 2019-05-14 22:09:14 -04:00 committed by Tyrel Souza
parent 8684aedbc2
commit 104aa44ef5
No known key found for this signature in database
GPG Key ID: 5A9394D4C30AEAC0
3 changed files with 18 additions and 9 deletions

View File

@ -9,6 +9,11 @@ import (
"github.com/urfave/cli"
)
/*
scan,s [directory-with-.tidelift.yml]
configure,c [directory-with-.tidelift.yml]
*/
func main() {
app := cli.NewApp()

View File

@ -3,6 +3,7 @@ package main
import (
"fmt"
"log"
"os"
"github.com/bmatcuk/doublestar"
)
@ -112,10 +113,11 @@ func manifestGlobs() []string {
}
func getListOfManifestFilenames(directory string) []string {
os.Chdir(directory)
matchingFiles := make([]string, 0)
for _, glob := range manifestGlobs() {
pathGlob := fmt.Sprintf("%s/**/%s", directory, glob)
pathGlob := fmt.Sprintf("**/%s", glob)
files := getListOfGlobMatches(pathGlob)
if len(files) > 0 {

View File

@ -1,6 +1,7 @@
package main
import (
"os"
"sort"
"testing"
@ -9,11 +10,12 @@ import (
func TestGetListOfGlobMatches(t *testing.T) {
//assert getManifestMatches gets all requirements.txt
os.Chdir("test/fixtures")
expected := []string{
"test/fixtures/subdir/requirements.txt",
"test/fixtures/a/b/c/d/e/f/g/requirements.txt",
"subdir/requirements.txt",
"a/b/c/d/e/f/g/requirements.txt",
}
got := getListOfGlobMatches("test/**/requirements.txt")
got := getListOfGlobMatches("**/requirements.txt")
sort.Strings(expected)
sort.Strings(got)
@ -22,12 +24,12 @@ func TestGetListOfGlobMatches(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",
"yarn.lock",
"Gemfile",
"a/b/c/d/e/f/g/requirements.txt",
"subdir/requirements.txt",
}
got := getListOfManifestFilenames("test/")
got := getListOfManifestFilenames("test/fixtures")
sort.Strings(expected)
sort.Strings(got)