5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-20 10:59:30 +08:00

Use relative paths in go.mod for replace line.

This commit is contained in:
Lea Anthony 2023-12-28 19:33:37 +11:00
parent b08126d745
commit 0974a3ad18
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405
2 changed files with 20 additions and 6 deletions

View File

@ -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) - 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) - 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 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 ### Changed

View File

@ -201,9 +201,26 @@ func getRemoteTemplate(uri string) (template *Template, err error) {
func Install(options *flags.Init) 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{ templateData := TemplateOptions{
options, options,
filepath.FromSlash(debug.LocalModulePath + "/"), filepath.ToSlash(relativePath + "/"),
} }
defer func() { defer func() {
@ -211,7 +228,6 @@ func Install(options *flags.Init) error {
_ = os.Remove(filepath.Join(templateData.ProjectDir, "template.json")) _ = os.Remove(filepath.Join(templateData.ProjectDir, "template.json"))
}() }()
var err error
var template *Template var template *Template
template, err = getInternalTemplate(options.TemplateName) template, err = getInternalTemplate(options.TemplateName)
if err != nil { if err != nil {
@ -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) 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 = projectDir
templateData.ProjectDir = lo.Must(os.Getwd())
}
templateData.ProjectDir = filepath.Join(options.ProjectDir, options.ProjectName)
// If project directory already exists and is not empty, error // If project directory already exists and is not empty, error
if _, err := os.Stat(templateData.ProjectDir); !os.IsNotExist(err) { if _, err := os.Stat(templateData.ProjectDir); !os.IsNotExist(err) {