[MM-27919] Allow i18n and resources to be loaded using an environment variable (#15341)
* [MM-27919] Allow i18n and resources to be loaded using an environment variable * Improve error message * Modify environment variable name to be less ambiguous Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
8ee5113a30
Коммит
49a75059c5
@@ -36,17 +36,26 @@ type testResourceDetails struct {
|
||||
action int8
|
||||
}
|
||||
|
||||
// commonBaseSearchPaths is a custom version of what fileutils exposes. At some point, consolidate.
|
||||
var commonBaseSearchPaths = []string{
|
||||
".",
|
||||
"..",
|
||||
"../..",
|
||||
"../../..",
|
||||
"../../../..",
|
||||
// getCommonBaseSearchPaths() is a custom version of what fileutils exposes. At some point, consolidate.
|
||||
func getCommonBaseSearchPaths() []string {
|
||||
paths := []string{
|
||||
".",
|
||||
"..",
|
||||
"../..",
|
||||
"../../..",
|
||||
"../../../..",
|
||||
}
|
||||
|
||||
// this enables the server to be used in tests from a different repository
|
||||
if mmPath := os.Getenv("MM_SERVER_PATH"); mmPath != "" {
|
||||
paths = append(paths, mmPath)
|
||||
}
|
||||
|
||||
return paths
|
||||
}
|
||||
|
||||
func findFile(path string) string {
|
||||
return fileutils.FindPath(path, commonBaseSearchPaths, func(fileInfo os.FileInfo) bool {
|
||||
return fileutils.FindPath(path, getCommonBaseSearchPaths(), func(fileInfo os.FileInfo) bool {
|
||||
return !fileInfo.IsDir()
|
||||
})
|
||||
}
|
||||
@@ -61,7 +70,7 @@ func findDir(dir string) (string, bool) {
|
||||
return path.Dir(srcPath), true
|
||||
}
|
||||
|
||||
found := fileutils.FindPath(dir, commonBaseSearchPaths, func(fileInfo os.FileInfo) bool {
|
||||
found := fileutils.FindPath(dir, getCommonBaseSearchPaths(), func(fileInfo os.FileInfo) bool {
|
||||
return fileInfo.IsDir()
|
||||
})
|
||||
if found == "" {
|
||||
|
||||
Ссылка в новой задаче
Block a user