Representation of a single package.json file.

await new PackageFile(opts).init();

Hierarchy (view full)

Constructors

Properties

Accessors

Methods

Constructors

Properties

Accessors

  • get name(): string
  • Package name. Asserts if not available. Must call init() first.

    Returns string

  • get private(): boolean
  • Is this package private?

    Returns boolean

  • get version(): string
  • Current version of the package.

    Returns string

  • set version(ver): void
  • Parameters

    • ver: string

    Returns void

  • get workspaces(): string[]
  • Workspaces as defined in the package file, if you are using npm-style workspaces.

    Returns string[]

Methods

  • Delete 0 or more fields from this file.

    Parameters

    • fields: string[]

      List of fields to delete.

    Returns this

    This, for chaining.

  • Get the set of local dependencies. Which of the local pacakges does this package depend upon?

    Parameters

    • locals: Set<string>

      The names of the local packages.

    Returns Set<string>

    The local packages we depend on.

  • Execute a command in the directory for this pacakge.

    Parameters

    • opts: SpawnOptions

      Options for spawn. {stdion: 'inherit'} is recommended.

    • command: string

      Shell command.

    Returns Promise<ExecResult>

    Results of execution when complete.

  • Read file in preparation for further processing. Must be called and awaited, before anything else.

    Returns Promise<PackageFile>

    This, for chaining.

  • Save the file if it is dirty.

    Parameters

    • gitAdd: boolean = false

      If true, also perform a "git add" on this file after saving.

    Returns Promise<PackageFile>

    This, for chaining.