Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Skip hidden directories when creating commands #6081

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/ddev/cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ func addCustomCommands(rootCmd *cobra.Command) error {
if !fileutil.IsDirectory(serviceDirOnHost) {
continue
}
// Skip hidden directories as well.
if strings.HasPrefix(filepath.Base(serviceDirOnHost), ".") {
continue
}
commandFiles, err := fileutil.ListFilesInDir(serviceDirOnHost)
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions cmd/ddev/cmd/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func TestCustomCommands(t *testing.T) {
assert.NotContains(out, "testwebglobal global (global shell web container command)")
assert.NotContains(out, "testhostcmd global")
assert.NotContains(out, "testwebcmd global")
assert.NotContains(out, "not-a-command")

out, err = exec.RunHostCommand(DdevBin, "testhostglobal-noproject", "hostarg1", "hostarg2", "--hostflag1")
assert.NoError(err)
Expand Down Expand Up @@ -140,6 +141,7 @@ func TestCustomCommands(t *testing.T) {
assert.Contains(out, "testwebglobal global (global shell web container command)")
assert.NotContains(out, "testhostcmd global") //the global testhostcmd should have been overridden by the project one
assert.NotContains(out, "testwebcmd global") //the global testwebcmd should have been overridden by the project one
assert.NotContains(out, "not-a-command")

// Have to do app.Start() because commands are copied into containers on start
err = app.Start()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

## Description: not-a-command global
## Usage: not-a-command
## Example: "ddev not-a-command"

echo "this file shouldn't display in the commands list"