Module deps_analyser
Static analyser of dependencies between Lua modules.
Functions
analyse (entry_point, pkg_path, predicate, flags) | Recursively resolves all dependencies (modules) of the given entry_point . |
analyse_with_filter (entry_points, pkg_path, excludes, flags) | Recursively analyses all dependencies (modules) of the given entry_points . |
Local Functions
locate_module (name, pkg_path) | Finds path of the given module name on the given pkg_path . |
resolve_requires (filename) | Resolves requires in the given Lua source file. |
expand_wildcard_require (pattern, pkg_path) | Expands the given module path in dot-notation (prefix) ended with a wildcard (e.g. |
filter_predicate (excludes, includes) | Creates a predicate function from the given list of positive and negative string patterns. |
convert_globs (patterns) | Converts glob patterns into Lua patterns. |
Functions
- analyse (entry_point, pkg_path, predicate, flags)
-
Recursively resolves all dependencies (modules) of the given
entry_point
.Flags:
- pcalls: Analyse pcall requires? (default: true)
- wildcards: Expand "wildcard" requires? (default: true)
Parameters:
- entry_point string Path of Lua script, or name of Lua module.
- pkg_path
optional string
The path where to look for modules (see package.searchpath).
Default is
<package.path>;<package.cpath>;;
. - predicate optional function The predicate function that is called with name of each module to be processed. When it returns true, the module is processed, otherwise it's skipped.
- flags optional {[string]=...} (See above)
Returns:
- {[string]=string,...} A map of found modules; key is the module name, value is the source file path.
- {string,...} A list of missing modules.
- {string,...} A list of ignored modules.
- {string,...} A list of error messages.
- analyse_with_filter (entry_points, pkg_path, excludes, flags)
-
Recursively analyses all dependencies (modules) of the given
entry_points
.Parameters:
- entry_points {string,...} or string Path(s) of Lua script, or name(s) of Lua module.
- pkg_path
optional string
The path where to look for modules (see package.searchpath).
Default is
<package.path>;<package.cpath>;;
. - excludes
optional {string,...}
Module(s) to exclude from the analysis; one or more
glob patterns matching module name in dot notation (e.g.
"pl.*"
). - flags optional {[string]=bool,...} See analyse.
Returns:
- {[string]=string,...} A map of found modules; key is the module name, value is the source file path.
- {string,...} A list of missing modules.
- {string,...} A list of ignored/excluded modules.
- {string,...} A list of error messages.
Local Functions
- locate_module (name, pkg_path)
-
Finds path of the given module
name
on the givenpkg_path
.Parameters:
- name string The module name in dot-notation.
- pkg_path string The path where to look for modules (see package.searchpath).
Returns:
-
string or nil
Location of the module file (may be relative), or nil if not found.
- resolve_requires (filename)
-
Resolves requires in the given Lua source file.
Parameters:
- filename string Path of the Lua source file to analyse.
Returns:
-
{table,...}
A list of require info. Each info table contains the following keys:
name
,line
,column
, and optionally:conditional
,lazy
,protected
.Or
- nil
- string An error message.
- expand_wildcard_require (pattern, pkg_path)
-
Expands the given module path in dot-notation (prefix) ended with a wildcard
(e.g.
lua-rocks.build.*
) to a list of all modules on thepkg_path
with the matching prefix.Parameters:
- pattern string The require string ended with a wildcard.
- pkg_path string The path where to look for modules (see package.searchpath).
Returns:
-
{string,...}
A list of module names.
- filter_predicate (excludes, includes)
-
Creates a predicate function from the given list of positive and negative string patterns.
Parameters:
- excludes {string,...} A list of patterns that should be excluded.
- includes optional {string,...} A list of patterns that should not be excluded.
Returns:
-
function
string -> bool
- convert_globs (patterns)
-
Converts glob patterns into Lua patterns.
Parameters:
- patterns {string,...} List of glob patterns.
Returns:
- {string,...} A list of positive patterns
- {string,...} A list of negative patterns.