Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PackageNode

Represents a package as a graph node.

Hierarchy

  • PackageNode

Implements

Index

Constructors

constructor

  • new PackageNode(manifest: IPackageJson, path: string): PackageNode

Properties

children

children: object = Object.create(null)

Child nodes inside of a node_modules path under this package.

Type declaration

dependencies

dependencies: IPackageNode[] = []

An array of resolved dependencies of this package.

dependencyResolved

dependencyResolved: boolean = false

Indicates all dependencies are resolved or not.

see

validate

id

id: string

A package's unique id as {package name}/{package version} format.

linked

linked: boolean = false

Indicates this node and it's dependencies are linked or not. This value is changed as true after linkDependencies call.

see

linkDependencies

manifest

manifest: IPackageJson

Contents of the package.json file of this package.

see

IPackageJson

name

name: string

Name of the package. The name field of package.json. If the name field of package.json is empty, directory name of the package will be used.

parent

parent: IPackageNode | undefined = void 0

An upper directory node of child nodes in a node_modules directory.

parent1/node_modules/child1

path

path: string

An absolute path of this node.

unresolvedDependencies

unresolvedDependencies: object

An array of dependencies which remain unresolved after dependency resolution try.

see

linkDependencies

Type declaration

  • [packageName: string]: string

validated

validated: boolean = false

Indicates this node is validated.

see

validate

Methods

getDependency

hasDependency

  • hasDependency(name: string, version?: undefined | string): boolean
  • Returns true if this node depends on the package with the given name and optional version.

    Parameters

    • name: string

      The name of a dependency.

    • Optional version: undefined | string

      The version of the dependency.

    Returns boolean

linkDependencies

  • linkDependencies(): void
  • For each unresolved dependencies, this method check if the dependency node exist, and if it exists and satisfies version then add to dependencies and remove from unresolvedDependencies.

    If the package.json has the optionalDependencies and some of it also exists unresolved dependencies, this method will remove them from the unresolved dependencies.

    Returns void

resolve

  • resolve(cb: function, resolveDevDependency?: undefined | false | true): void
  • Calls linkDependencies, then calls validate

    Parameters

    • cb: function

      Called when the resolution process for this node has been ended.

        • (node: IPackageNode, unresolvedNodeNames?: string[]): void
        • Parameters

          Returns void

    • Optional resolveDevDependency: undefined | false | true

      If this value is true this node will resolve devDependencies too.

    Returns void

toString

  • toString(): string

validate

  • validate(cb: function): boolean
  • Validates all of this node's dependencies recursively.

    Parameters

    • cb: function
        • Parameters

          Returns void

    Returns boolean

Generated using TypeDoc