Constructor
new Package(deploymentConfig, lock, parent, name, versionSpec, baseDir, production, sourcesCache)
Creates a new package object.
Parameters:
| Name | Type | Description |
|---|---|---|
deploymentConfig |
DeploymentConfig | An object capturing global deployment settings |
lock |
Object | Contents of a package lock file (or undefined if no lock exists) |
parent |
Package | Reference to the package that embeds the constructed package, or null if there is no parent |
name |
String | Name of a Node.js package |
versionSpec |
String | Version specifier of a Node.js package, such as an exact version number, version range, URL, or GitHub identifier |
baseDir |
String | Directory in which the referrer's package.json configuration resides |
production |
Boolean | Indicates whether we deploy in production mode or development mode. In development mode, also the development dependencies will be included. |
sourcesCache |
SourcesCache | Cache that contains references to all sources that need to be obtained |
- Source:
Extends
- NixASTNode
Methods
bundleDependencies(resolvedDependencies, dependencies, callback)
Bundles a collection of dependencies with this package (or when flattening
mode has been enabled) any parent package that does not conflict and
automatically fetches its metadata by downloading it.
Parameters:
| Name | Type | Description |
|---|---|---|
resolvedDependencies |
Array.<Package> | Memorizes the dependencies that have been resolved so that we can resolve their transitive dependencies later. |
dependencies |
Array.<Package> | Dependencies to bundle with the package |
callback |
function | Callback that gets invoked then the work is done. The first parameter is set to an error object if the operation fails. |
- Source:
bundleDependency(dependencyName, pkg)
Bundles a dependency (that is fetched from an external location) to the
package (or a parent package if flattening has been enabled). A bundled
package will appear in the node_modules/ sub folder of the package.
Parameters:
| Name | Type | Description |
|---|---|---|
dependencyName |
String | Name of the dependency |
pkg |
Package | Package to bundle in the node_modules/ sub folder |
- Source:
findMatchingProvidedDependencyByParent(name, versionSpec) → {Package}
Recursively checks the enclosing parent packages to see whether a dependency
exists that fits within the required version range.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
String | Name of a Node.js package |
versionSpec |
String | Version specifier of a Node.js package, such as an exact version number, version range, URL, or GitHub identifier |
- Source:
Returns:
The nearest parent package matching the version specifier
or null if no such package exists
- Type
- Package
generateDependencyAST() → {Array}
Composes an abstract syntax tree for the provided NPM dependencies by this
package.
- Source:
Returns:
An array representing a list of NPM package dependencies
- Type
- Array
isBundledDependency(dependencyName) → {Boolean}
Checks whether a dependency with a given name is already bundled with this
package.
Parameters:
| Name | Type | Description |
|---|---|---|
dependencyName |
String | Name of the dependency |
- Source:
Returns:
true if the dependency is bundled, else false
- Type
- Boolean
resolveDependencies(callback)
Resolves all dependencies and transitive dependencies of this package.
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
function | Callback that gets invoked then the work is done. The first parameter is set to an error object if the operation fails. |
- Source:
toNixAST()
- Source:
- See:
-
- NixASTNode#toNixAST