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

chore: comments of #4125 #4135

Merged
merged 6 commits into from
May 13, 2024
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
7 changes: 6 additions & 1 deletion ignite/config/plugins/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,19 @@ func RemoveDuplicates(plugins []Plugin) (unique []Plugin) {
return unique
}

// IsLocalPath returns true if the path is a local directory.
func IsLocalPath(path string) bool {
return strings.HasPrefix(path, "/") || strings.HasPrefix(path, ".") || strings.HasPrefix(path, "~")
}

// IsGlobal returns whether the plugin is installed globally or locally for a chain.
func (p Plugin) IsGlobal() bool {
return p.Global
}

// IsLocalPath returns true if the plugin path is a local directory.
func (p Plugin) IsLocalPath() bool {
return strings.HasPrefix(p.Path, "/") || strings.HasPrefix(p.Path, ".") || strings.HasPrefix(p.Path, "~")
return IsLocalPath(p.Path)
}

// HasPath verifies if a plugin has the given path regardless of version.
Expand Down
2 changes: 1 addition & 1 deletion ignite/services/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func newPlugin(pluginsDir string, cp pluginsconfig.Plugin, options ...Option) *P
}

// This is a local plugin, check if the file exists
if tp := (&Plugin{Plugin: pluginsconfig.Plugin{Path: pluginPath}}); tp.IsLocalPath() {
if pluginsconfig.IsLocalPath(pluginPath) {
// if directory is relative, make it absolute
if !filepath.IsAbs(pluginPath) {
pluginPathAbs, err := filepath.Abs(pluginPath)
Expand Down
Loading