这是indexloc提供的服务,不要输入任何密码
Skip to content

Options cleanup #1295

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

Merged
merged 10 commits into from
May 31, 2022
Merged
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
3 changes: 2 additions & 1 deletion cli/internal/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ func isWorkspaceReference(packageVersion string, dependencyVersion string, cwd s

// WithGraph attaches information about the package dependency graph to the Context instance being
// constructed.
func WithGraph(rootpath string, config *config.Config, cacheDir fs.AbsolutePath) Option {
func WithGraph(config *config.Config, cacheDir fs.AbsolutePath) Option {
return func(c *Context) error {
rootpath := config.Cwd.ToStringDuringMigration()
c.PackageInfos = make(map[interface{}]*fs.PackageJSON)
c.RootNode = core.ROOT_NODE_NAME

Expand Down
5 changes: 5 additions & 0 deletions cli/internal/fs/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ func (ap AbsolutePath) Create() (*os.File, error) {
return os.Create(ap.asString())
}

// Ext implements filepath.Ext for an absolute path
func (ap AbsolutePath) Ext() string {
return filepath.Ext(ap.asString())
}

// ToString returns the string representation of this absolute path. Used for
// interfacing with APIs that require a string
func (ap AbsolutePath) ToString() string {
Expand Down
2 changes: 1 addition & 1 deletion cli/internal/prune/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (c *PruneCommand) Run(args []string) int {
return 1
}
cacheDir := cache.DefaultLocation(c.Config.Cwd)
ctx, err := context.New(context.WithGraph(pruneOptions.cwd, c.Config, cacheDir))
ctx, err := context.New(context.WithGraph(c.Config, cacheDir))

if err != nil {
c.logError(c.Config.Logger, "", fmt.Errorf("could not construct graph: %w", err))
Expand Down
Loading