Documentation
¶
Overview ¶
Package jsdependency provides helpers to build npm/yarn install and remove commands for a detected JS package manager.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCommand ¶
func AddCommand(factory command.Factory, tool Tool, scope CommandScope, pkgs ...string) command.Command
AddCommand returns the command that installs the given packages in the requested scope for the given tool, built via factory.
func RemoveCommand ¶
func RemoveCommand(factory command.Factory, tool Tool, scope CommandScope, pkgs ...string) command.Command
RemoveCommand returns the command that removes the given packages in the requested scope for the given tool, built via factory.
Types ¶
type CommandScope ¶
type CommandScope string
CommandScope describes whether a package manager command applies globally or locally.
const ( Local CommandScope = "local" Global CommandScope = "global" )
Supported command scopes.
type InstallCommand ¶
InstallCommand pairs a command with a flag indicating whether its failure can be ignored (e.g. yarn exits non-zero when removing a package that is not installed).
func InstallGlobalDependencyCommand ¶
func InstallGlobalDependencyCommand(factory command.Factory, tool Tool, dependency, version string) ([]InstallCommand, error)
InstallGlobalDependencyCommand returns the sequence of commands that removes any existing local copy and adds the dependency globally at the requested version.
type Tool ¶
type Tool string
Tool identifies a JS package manager.
func DetectTool ¶
DetectTool reports which JS package manager to use by checking for a yarn.lock file next to package.json. Falls back to Npm when absent.