Skip to content

Commit

Permalink
refactor: Use path/filepath instead of path (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn authored Nov 8, 2021
1 parent b8fa12f commit 053361d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions storybook/storybook.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os"
"os/exec"
"path"
"path/filepath"
"reflect"
"strconv"
"strings"
Expand Down Expand Up @@ -192,7 +193,7 @@ func (sh *Storybook) installStorybook() (err error) {

func (sh *Storybook) configureStorybook() (configHasChanged bool, err error) {
// Delete template/existing files in the stories directory.
storiesDir := path.Join(sh.Path, "stories")
storiesDir := filepath.Join(sh.Path, "stories")
before, err := dirhash.HashDir(storiesDir, "/", dirhash.DefaultHash)
if err != nil && !os.IsNotExist(err) {
return configHasChanged, err
Expand All @@ -205,7 +206,7 @@ func (sh *Storybook) configureStorybook() (configHasChanged bool, err error) {
}
// Create new *.stories.json files.
for _, c := range sh.Config {
name := path.Join(sh.Path, fmt.Sprintf("stories/%s.stories.json", c.Title))
name := filepath.Join(sh.Path, fmt.Sprintf("stories/%s.stories.json", c.Title))
f, err := os.Create(name)
if err != nil {
return configHasChanged, fmt.Errorf("failed to create config file to %q: %w", name, err)
Expand All @@ -218,7 +219,7 @@ func (sh *Storybook) configureStorybook() (configHasChanged bool, err error) {
after, err := dirhash.HashDir(storiesDir, "/", dirhash.DefaultHash)
configHasChanged = before != after
// Configure storybook Preview URL.
err = os.WriteFile(path.Join(sh.Path, ".storybook/preview.js"), []byte(previewJS), os.ModePerm)
err = os.WriteFile(filepath.Join(sh.Path, ".storybook/preview.js"), []byte(previewJS), os.ModePerm)
return
}

Expand Down

0 comments on commit 053361d

Please sign in to comment.