Skip to content

Commit

Permalink
fix: make why work with Windows path
Browse files Browse the repository at this point in the history
  • Loading branch information
majori committed Nov 15, 2024
1 parent 8b5c79f commit 9bf7851
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/cli/why.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ func runWhy(cmd *cobra.Command, opts whyOptions) error {

for _, sauce := range sauces {
for file := range sauce.Files {
if fileinfo.IsDir() {
if strings.HasPrefix(file, opts.Filepath) {
cmd.Printf("Directory '%s' is created by the recipe '%s' (sauce ID %s).\n", opts.Filepath, sauce.Recipe.Name, sauce.ID)
return nil
}
cleanedFilePath := filepath.Clean(file)
if fileinfo.IsDir() && strings.HasPrefix(cleanedFilePath, opts.Filepath) {
cmd.Printf("Directory '%s' is created by the recipe '%s' (sauce ID %s).\n", opts.Filepath, sauce.Recipe.Name, sauce.ID)
return nil
}
if opts.Filepath == file {

if opts.Filepath == cleanedFilePath {
// TODO: Check if the file is modified by the user by comparing hashes
cmd.Printf("File '%s' is created by the recipe '%s' (sauce ID %s).\n", opts.Filepath, sauce.Recipe.Name, sauce.ID)
return nil
Expand Down

0 comments on commit 9bf7851

Please sign in to comment.