Skip to content

Commit

Permalink
Use relative paths in go.mod for replace line.
Browse files Browse the repository at this point in the history
  • Loading branch information
leaanthony committed Dec 28, 2023
1 parent b08126d commit 0974a3a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions mkdocs-website/docs/en/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Set drag-n-drop for windows to working. Added by [@pylotlight](https://github.com/pylotlight) in [PR](https://github.com/wailsapp/wails/pull/3039)
- Fixed bug for linux in doctor in the event user doesn't have proper drivers installed. Added by [@pylotlight](https://github.com/pylotlight) in [PR](https://github.com/wailsapp/wails/pull/3032)
- Fix dpi scaling on start up (windows). Changed by @almas1992 in [PR](https://github.com/wailsapp/wails/pull/3145)
- Fix replace line in `go.mod` to use relative paths. Fixes Windows paths with spaces - @leaanthony.

### Changed

Expand Down
25 changes: 19 additions & 6 deletions v3/internal/templates/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,33 @@ func getRemoteTemplate(uri string) (template *Template, err error) {

func Install(options *flags.Init) error {

var projectDir string
if options.ProjectDir == "." || options.ProjectDir == "" {
projectDir = lo.Must(os.Getwd())
}
var err error
projectDir, err = filepath.Abs(filepath.Join(options.ProjectDir, options.ProjectName))
if err != nil {
return err
}

// Calculate relative path from project directory to LocalModulePath
var relativePath string
relativePath, err = filepath.Rel(projectDir, debug.LocalModulePath)
if err != nil {
return err
}

templateData := TemplateOptions{
options,
filepath.FromSlash(debug.LocalModulePath + "/"),
filepath.ToSlash(relativePath + "/"),
}

defer func() {
// if `template.json` exists, remove it
_ = os.Remove(filepath.Join(templateData.ProjectDir, "template.json"))
}()

var err error
var template *Template
template, err = getInternalTemplate(options.TemplateName)
if err != nil {
Expand All @@ -234,10 +250,7 @@ func Install(options *flags.Init) error {
return fmt.Errorf("invalid template name: %s. Use -l flag to view available templates or use a valid filepath / url to a template", options.TemplateName)
}

if options.ProjectDir == "." || options.ProjectDir == "" {
templateData.ProjectDir = lo.Must(os.Getwd())
}
templateData.ProjectDir = filepath.Join(options.ProjectDir, options.ProjectName)
templateData.ProjectDir = projectDir

// If project directory already exists and is not empty, error
if _, err := os.Stat(templateData.ProjectDir); !os.IsNotExist(err) {
Expand Down

0 comments on commit 0974a3a

Please sign in to comment.