chdir
This commit is contained in:
parent
8684aedbc2
commit
104aa44ef5
5
main.go
5
main.go
@ -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()
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user