mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-14 12:48:04 -08:00
fix(sitecore): replace HasFiles with HasFilesInDir
This commit is contained in:
parent
8ff47c7f65
commit
67deabffda
|
@ -33,13 +33,15 @@ type UserConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Sitecore) Enabled() bool {
|
func (s *Sitecore) Enabled() bool {
|
||||||
if !s.env.HasFiles(sitecoreFileName) || !s.env.HasFiles(path.Join(sitecoreFolderName, userFileName)) {
|
if !s.env.HasFiles(sitecoreFileName) || !s.env.HasFilesInDir(sitecoreFolderName, userFileName) {
|
||||||
|
s.env.Debug("sitecore cli configuration files were not found")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
var userConfig, err = getUserConfig(s)
|
var userConfig, err = getUserConfig(s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
s.env.Error(err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +50,7 @@ func (s *Sitecore) Enabled() bool {
|
||||||
displayDefault := s.props.GetBool(properties.DisplayDefault, true)
|
displayDefault := s.props.GetBool(properties.DisplayDefault, true)
|
||||||
|
|
||||||
if !displayDefault && s.EndpointName == defaultEnpointName {
|
if !displayDefault && s.EndpointName == defaultEnpointName {
|
||||||
|
s.env.Debug("displaying of the default environment is turned off")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/jandedobbeleer/oh-my-posh/src/runtime/mock"
|
"github.com/jandedobbeleer/oh-my-posh/src/runtime/mock"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
testify_ "github.com/stretchr/testify/mock"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSitecoreSegment(t *testing.T) {
|
func TestSitecoreSegment(t *testing.T) {
|
||||||
|
@ -86,8 +87,10 @@ func TestSitecoreSegment(t *testing.T) {
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
env := new(mock.Environment)
|
env := new(mock.Environment)
|
||||||
env.On("HasFiles", "sitecore.json").Return(tc.SitecoreFileExists)
|
env.On("HasFiles", "sitecore.json").Return(tc.SitecoreFileExists)
|
||||||
env.On("HasFiles", path.Join(".sitecore", "user.json")).Return(tc.UserFileExists)
|
env.On("HasFilesInDir", ".sitecore", "user.json").Return(tc.UserFileExists)
|
||||||
env.On("FileContent", path.Join(".sitecore", "user.json")).Return(tc.UserFileContent)
|
env.On("FileContent", path.Join(".sitecore", "user.json")).Return(tc.UserFileContent)
|
||||||
|
env.On("Debug", testify_.Anything)
|
||||||
|
env.On("Error", testify_.Anything)
|
||||||
|
|
||||||
props := properties.Map{
|
props := properties.Map{
|
||||||
properties.DisplayDefault: tc.DisplayDefault,
|
properties.DisplayDefault: tc.DisplayDefault,
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
{
|
|
||||||
"endpoints": {
|
|
||||||
"default": {
|
|
||||||
"ref": "xmcloud",
|
|
||||||
"allowWrite": true,
|
|
||||||
"host": "https://xmc-sitecore<someID>-projectName-environmentName.sitecorecloud.io",
|
|
||||||
"variables": {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
{
|
|
||||||
"endpoints": {
|
|
||||||
"default": {
|
|
||||||
"ref": "local",
|
|
||||||
"allowWrite": true,
|
|
||||||
"host": "https://xmcloudcm.local",
|
|
||||||
"variables": {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue