Skip to content

Commit

Permalink
fix: source in readme from current directory
Browse files Browse the repository at this point in the history
  • Loading branch information
mahyarmirrashed committed Dec 20, 2024
1 parent 7d0487e commit 00a42f1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"os"
"path/filepath"
"regexp"
"strings"

Expand All @@ -15,8 +16,6 @@ import (
"github.com/spf13/cobra"
)

const readmePath = "README.md"

var includes []string

var rootCmd = &cobra.Command{
Expand All @@ -33,6 +32,15 @@ var rootCmd = &cobra.Command{
log.Debug().Msgf("Stats to include: %s", includes)
log.Debug().Msgf("Timezone: %s", cfg.TimeZone)

// Get the current working directory
cwd, err := os.Getwd()
if err != nil {
return fmt.Errorf("failed to get current working directory: %w", err)
}
path := filepath.Join(cwd, "README.md")

log.Debug().Msgf("Path for readme is: %s", path)

// Create GraphQL client
client := github.NewClient(cfg.GithubToken)
ctx := context.Background()
Expand Down Expand Up @@ -95,7 +103,7 @@ var rootCmd = &cobra.Command{
contentBuilder.WriteString("\n")

// Update the README file
if err := updateReadme(readmePath, contentBuilder.String()); err != nil {
if err := updateReadme(path, contentBuilder.String()); err != nil {
return fmt.Errorf("failed to update README: %w", err)
}

Expand Down

0 comments on commit 00a42f1

Please sign in to comment.