Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use filepath.Join for cross-platform compatible file path construction #112

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkl/decode_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (d *decoder) decodeMap(inType reflect.Type) (*reflect.Value, error) {
return d.decodeSet(inType)
}
if code != codeMap && code != codeMapping {
return nil, fmt.Errorf("invalid code for slices: %d", code)
return nil, fmt.Errorf("invalid code for maps: %d", code)
}
return d.decodeMapImpl(inType)
}
Expand Down
12 changes: 9 additions & 3 deletions pkl/evaluator_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

package pkl

import "context"
import (
"context"
"path/filepath"
)

// NewEvaluator returns an evaluator backed by a single EvaluatorManager.
// Its manager gets closed when the evaluator is closed.
Expand Down Expand Up @@ -45,7 +48,7 @@ func NewProjectEvaluator(ctx context.Context, projectDir string, opts ...func(op
// pklCmd is treated as the base command that spawns Pkl.
// For example, the below snippet spawns the command /opt/bin/pkl.
//
// NewProjectEvaluatorWithCommand(context.Background(), []string{"/opt/bin/pkl"}, "/path/to/my/project")
// NewProjectEvaluatorWithCommand(context.Background(), "/path/to/my/project", []string{"/opt/bin/pkl"})
//
// If creating multiple evaluators, prefer using EvaluatorManager.NewProjectEvaluator instead,
// because it lessens the overhead of each successive evaluator.
Expand All @@ -55,7 +58,10 @@ func NewProjectEvaluatorWithCommand(ctx context.Context, projectDir string, pklC
if err != nil {
return nil, err
}
project, err := LoadProjectFromEvaluator(ctx, projectEvaluator, projectDir+"/PklProject")
defer projectEvaluator.Close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this was a bad bug. Good catch!


projectPath := filepath.Join(projectDir, "PklProject")
project, err := LoadProjectFromEvaluator(ctx, projectEvaluator, projectPath)
if err != nil {
return nil, err
}
Expand Down