2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-11-16 18:26:13 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
// +build ignore
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
cmd := exec.Command("git", "ls-files", ".", "--others")
|
|
|
|
|
|
|
|
out, err := cmd.Output()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("Checking left-over files failed.")
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
2019-04-24 16:33:01 +01:00
|
|
|
leftover := strings.Split(strings.TrimSpace(string(out)), "\n")
|
2019-09-05 14:32:46 +01:00
|
|
|
leftover = ignorePrefix(leftover, ".build")
|
|
|
|
|
|
|
|
// there's no easy way to modify npm to use tmp folders
|
|
|
|
leftover = ignorePrefix(leftover, "web/satellite/node_modules/")
|
|
|
|
leftover = ignorePrefix(leftover, "web/satellite/coverage/")
|
|
|
|
leftover = ignorePrefix(leftover, "web/satellite/dist/")
|
|
|
|
// TODO: shouldn't this be already up to date?
|
|
|
|
leftover = ignorePrefix(leftover, "web/satellite/package-lock.json")
|
2019-04-24 16:33:01 +01:00
|
|
|
|
|
|
|
if len(leftover) != 0 {
|
2018-11-16 18:26:13 +00:00
|
|
|
fmt.Println("Files left-over after running tests:")
|
2019-04-24 16:33:01 +01:00
|
|
|
for _, file := range leftover {
|
|
|
|
fmt.Println(file)
|
|
|
|
}
|
2018-11-16 18:26:13 +00:00
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|
2019-04-24 16:33:01 +01:00
|
|
|
|
2019-09-05 14:32:46 +01:00
|
|
|
func ignorePrefix(files []string, dir string) []string {
|
2019-04-24 16:33:01 +01:00
|
|
|
result := files[:0]
|
|
|
|
for _, file := range files {
|
|
|
|
if file == "" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if strings.HasPrefix(file, dir) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
result = append(result, file)
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|