github.com/randomtask1155/cli@v6.41.1-0.20181227003417-a98eed78cbde+incompatible/integration/helpers/file.go (about) 1 package helpers 2 3 import ( 4 "fmt" 5 "path/filepath" 6 "regexp" 7 "strings" 8 9 . "github.com/onsi/gomega" 10 ) 11 12 // ConvertPathToRegularExpression converts a windows file path into a 13 // string which may be embedded in a ginkgo-compatible regular expression. 14 func ConvertPathToRegularExpression(path string) string { 15 return strings.Replace(path, "\\", "\\\\", -1) 16 } 17 18 func OSAgnosticPath(baseDir string, template string, args ...interface{}) string { 19 theRealPath, err := filepath.EvalSymlinks(baseDir) 20 Expect(err).ToNot(HaveOccurred()) 21 return regexp.QuoteMeta(filepath.Join(theRealPath, fmt.Sprintf(template, args...))) 22 }