Documentation
¶
Index ¶
- Variables
- func InstallDependencies(ctx context.Context, exec executor.Executor, pkg *Package, ...) error
- func InstallDependenciesStreamed(ctx context.Context, exec executor.Executor, pkg *Package, out io.Writer, ...) error
- func NodeModulesExists(root string) bool
- func PatchPackageLockToRemoveCanIUse(packageLockPath string) error
- type Package
Constants ¶
This section is empty.
Variables ¶
var NonEmptyPackage = &Package{Dependencies: map[string]string{"not-empty": "not-empty"}}
NonEmptyPackage returns a Package with a dummy dependency. This is useful when you need to run npm install but don't have a package.json to read.
Functions ¶
func InstallDependencies ¶
func InstallDependencies(ctx context.Context, exec executor.Executor, pkg *Package, additionalParams ...string) error
InstallDependencies runs npm install using the given executor. Additional parameters can be passed to customize the install behavior.
func InstallDependenciesStreamed ¶
func InstallDependenciesStreamed(ctx context.Context, exec executor.Executor, pkg *Package, out io.Writer, additionalParams ...string) error
InstallDependenciesStreamed behaves like InstallDependencies but, when out is non-nil, streams the combined npm output to it live instead of buffering it and only surfacing it on failure.
func NodeModulesExists ¶
NodeModulesExists checks if a node_modules directory exists in the given root.
func PatchPackageLockToRemoveCanIUse ¶
PatchPackageLockToRemoveCanIUse removes caniuse-lite from a package-lock.json file. This is needed because the caniuse-lite package is often outdated in lock files and causes issues with browserslist.
Types ¶
type Package ¶
type Package struct {
Dependencies map[string]string `json:"dependencies"`
DevDependencies map[string]string `json:"devDependencies"`
Scripts map[string]string `json:"scripts"`
}
Package represents a parsed package.json file.
func ReadPackage ¶
ReadPackage reads and parses a package.json file from the given directory.
func (Package) HasDevDependency ¶
HasDevDependency checks if the package.json contains a dev dependency with the given name.