EditorConfig.Glob (EditorConfig v0.1.0)

Copy Markdown View Source

EditorConfig section glob compiler and matcher.

Summary

Functions

Compiles an EditorConfig section glob.

Checks whether a path matches an EditorConfig section glob.

Functions

compile(pattern)

@spec compile(String.t()) :: {:ok, EditorConfig.Glob.Compiled.t()} | {:error, term()}

Compiles an EditorConfig section glob.

Examples

iex> {:ok, compiled} = EditorConfig.Glob.compile("*.ex")
iex> compiled.pattern
"*.ex"

match?(pattern, path, config_dir)

@spec match?(String.t(), Path.t(), Path.t()) :: boolean()

Checks whether a path matches an EditorConfig section glob.

Examples

iex> EditorConfig.Glob.match?("lib/*.ex", "/project/lib/file.ex", "/project")
true