Skip to content

Commit

Permalink
add ReflectToWorkingTree method for object (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
JunNishimura committed Jun 18, 2023
1 parent bcaef8d commit ca78f48
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions internal/object/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,19 @@ func (o *Object) Write(rootGoitPath string) error {
}
return nil
}

func (o *Object) ReflectToWorkingTree(rootGoitPath, path string) error {
rootDir := filepath.Dir(rootGoitPath)
filePath := filepath.Join(rootDir, path)
f, err := os.Create(filePath)
if err != nil {
return fmt.Errorf("fail to create file %s: %w", filePath, err)
}
defer f.Close()

if _, err := f.Write(o.Data); err != nil {
return fmt.Errorf("fail to write object to %s: %w", filePath, err)
}

return nil
}

0 comments on commit ca78f48

Please sign in to comment.