Package class
Package is the manager of Flux packages.
This library is the centralized controlling mechanism for them. Individual packages are represented by PackageInstance objects.
Summary
Methods
Methods
Adds a search path relative to the 'LUA' system.
Parameters
- path String folder to look for packages in; a trailing slash is added if missing
Returns
- Package self
Returns -1 if version1 is older than version2. Returns 0 if versions are equal. Returns 1 if version1 is newer than version2.
Parameters
- version1 Map version data from Package:parse_version
- version2 Map version data from Package:parse_version
Returns
- Number/Boolean -1, 0 or 1; false if either argument is not a table
Describes the current package's specification.
A field may be given in its plural form, such as authors or files, and is stored under
the singular one. Once the globals are set up, the dependencies are included.
Package:describe(function(s)
s.name = 'Example Package'
s.version = '1.0'
s.date = '2019-03-09'
s.summary = 'Brief summary of what the package does.'
s.description = 'A more detailed description of what the package does.'
s.authors = { 'Flux Developer' }
s.email = 'example@example.com'
s.files = { 'lib/example.lua', 'config/example.lua' }
s.global = 'ExamplePackage'
s.website = 'https://example.com'
s.license = 'MIT'
s.depends 'random_dependency'
if IS_DEVELOPMENT then
s.depends 'random_development_package'
end
end)
Parameters
- callback Function optional, defaults to
nilreceives the specification object to fill in as its only argument
Returns
- PackageInstance
Searches for the package with the specified name and returns true if the package exists, false otherwise.
Parameters
- name String package name, or path to the package's folder
Returns
- Boolean
Searches for a package with the specified name and returns the full path to its packagespec, the name of the package and the full path to the folder. Returns false if the package cannot be found.
Parameters
- name String package name, or path to the package's folder
Returns
- String/Boolean packagespec path or false if not found
- String name
- String folder path
Attempts to include the package with the specified name. This function will look for the package in the search paths that have previously been added. If no package with the matching name can be found, throws an error.
Parameters
- name String package name, or path to the package's folder
- _version String optional, defaults to
nilignored
Returns
- Boolean true if name is a .lua file, which is skipped; nothing otherwise
See also
Determines if the package has already been installed.
Parameters
- name String package name
Returns
- Boolean
Aliases
Package.presentPackage.is_installed
Returns true if version2 matches the version1 template.
Parameters
- version1 Map version data of the template, its op field sets the comparison
- version2 Map version data of the version to check
Returns
- Boolean
Parse a version string.
Package:parse_version('~> 1.2.3-beta')
-- { x = 1, y = 2, z = 3, sum = 123, suffix = 'beta', op = '~>' }
Parameters
- version String version such as '1.0', '>= 1.2.0' or '~> 1.2.3-beta'
Returns
- Map version data with the fields x, y, z, sum, suffix and op
Reloads the package with the specified name. Does nothing unless the package is installed and its specification allows reloading.
Parameters
- name String package name