Skip to content

Commit

Permalink
add dep version json file
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 committed Jan 29, 2024
1 parent 4a1ea53 commit 2f98ded
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ func (c *Config) StateFile() string {
return filepath.Join(c.CacheDir(), constants.StateFilename)
}

func (c *Config) DepVersionFile() string {
return filepath.Join(c.CacheDir(), constants.DepVersionFilename)
}

func (c *Config) QuestionCacheFile(ext string) string {
return filepath.Join(c.CacheDir(), constants.QuestionCacheBaseName+ext)
}
Expand Down
1 change: 1 addition & 0 deletions constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const (
ConfigFilename = "leetgo.yaml"
QuestionCacheBaseName = "leetcode-questions"
StateFilename = "state.json"
DepVersionFilename = "dep.json"
CodeBeginMarker = "@lc code=begin"
CodeEndMarker = "@lc code=end"
ProjectURL = "https://github.com/j178/leetgo"
Expand Down
4 changes: 2 additions & 2 deletions lang/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var depVersions = map[string]string{
}

func readDepVersions() (map[string]string, error) {
depVersionFile := config.Get().CacheDir() // TODO change to config.Get().DepVersionFile()
depVersionFile := config.Get().DepVersionFile()
records := make(map[string]string)
f, err := os.Open(depVersionFile)
if err != nil {
Expand Down Expand Up @@ -68,7 +68,7 @@ func UpdateDep(lang Lang) error {

records[lang.Slug()] = ver

depVersionFile := config.Get().CacheDir()
depVersionFile := config.Get().DepVersionFile()
f, err := os.Create(depVersionFile)
if err != nil {
return err
Expand Down

0 comments on commit 2f98ded

Please sign in to comment.