Help us shape the future of Go! Take the 2026 Go Developer Survey

node

package
v1.36.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDependenciesUpToDate

func IsDependenciesUpToDate(projectDir string, pm PackageManagerKind) bool

IsDependenciesUpToDate checks if node_modules is up-to-date relative to the lock file. This avoids unnecessary reinstalls when dependencies haven't changed. Pattern borrowed from azd-app extension's installer.

Types

type Cli

type Cli interface {
	tools.ExternalTool
	Install(ctx context.Context, projectPath string, env []string) error
	RunScript(ctx context.Context, projectPath string, scriptName string, env []string) error
	Prune(ctx context.Context, projectPath string, production bool, env []string) error
	PackageManager() PackageManagerKind
}

Cli defines the interface for Node.js package manager operations. Separate implementations for npm, pnpm, and yarn handle PM-specific behaviors.

func NewCli

func NewCli(commandRunner exec.CommandRunner) Cli

NewCli creates a CLI using the default package manager (npm).

func NewCliWithPackageManager

func NewCliWithPackageManager(commandRunner exec.CommandRunner, pm PackageManagerKind) Cli

NewCliWithPackageManager creates a CLI for the specified package manager.

type PackageManagerKind

type PackageManagerKind string

PackageManagerKind represents the type of Node.js package manager.

const (
	PackageManagerNpm  PackageManagerKind = "npm"
	PackageManagerPnpm PackageManagerKind = "pnpm"
	PackageManagerYarn PackageManagerKind = "yarn"
)

func DetectPackageManager

func DetectPackageManager(projectDir string) PackageManagerKind

DetectPackageManager determines the Node.js package manager to use for a given project directory. Detection priority (matches azd-app extension):

  1. "packageManager" field in package.json (e.g., "pnpm@8.15.0")
  2. Lock file presence: pnpm-lock.yaml → pnpm-workspace.yaml → yarn.lock → package-lock.json
  3. Default: npm

Jump to

Keyboard shortcuts

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