npm

package
v3.90.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Install

func Install(ctx context.Context, dir string, production bool, stdout, stderr io.Writer) (string, error)

Install runs `npm install` in the given directory, installing the dependencies for the Node.js app located there. If the `PULUMI_PREFER_YARN` environment variable is set, `yarn install` is used instead of `npm install`. The returned string is the name of the package manager used during installation.

func Pack

func Pack(ctx context.Context, dir string, stderr io.Writer) ([]byte, error)

Pack runs `npm pack` in the given directory, packaging the Node.js app located there into a tarball and returning it as `[]byte`. `stdout` is ignored for the command, as it does not generate useful data. If the `PULUMI_PREFER_YARN` environment variable is set, `yarn pack` is run instead of `npm pack`.

Types

type PackageManager added in v3.69.0

type PackageManager interface {
	// Install will install dependencies with the given package manager.
	Install(ctx context.Context, dir string, production bool, stdout, stderr io.Writer) error
	Pack(ctx context.Context, dir string, stderr io.Writer) ([]byte, error)
	// Name is the name of the binary executable used to invoke this package manager.
	// e.g. yarn or npm
	Name() string
}

A `PackageManager` is responsible for installing dependencies, packaging Pulumi programs, and executing Node in the context of installed packages. In practice, each implementation of this interface represents one of the package managers in the Node ecosystem e.g. Yarn, NPM, etc. The language host will dynamically dispatch to an instance of PackageManager in response to RPC requests.

func ResolvePackageManager added in v3.69.0

func ResolvePackageManager(pwd string) (PackageManager, error)

ResolvePackageManager determines which package manager to use. It inspects the value of "PULUMI_PREFER_YARN" and checks for a yarn.lock file. If neither of those values are enabled or truthy, then it uses NPM over YarnClassic. The argument pwd is the present working directory we're checking for the presence of a lockfile.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL