Skip to main content

functions/packageManager

Functions

getPackageManagerAddCommand()

function getPackageManagerAddCommand(packageManager, dependency): string

Helper function to get the add command for a package manager. For example, the command for npm is: npm install foo --save

Parameters

ParameterType
packageManagerPackageManager
dependencystring

Returns

string

Defined in

functions/packageManager.ts:32


getPackageManagerAddDevCommand()

function getPackageManagerAddDevCommand(packageManager, dependency): string

Helper function to get the add development command for a package manager. For example, the command for npm is: npm install foo --save-dev

Parameters

ParameterType
packageManagerPackageManager
dependencystring

Returns

string

Defined in

functions/packageManager.ts:59


getPackageManagerExecCommand()

function getPackageManagerExecCommand(packageManager): string

Helper function to get the exec command for a package manager. For example, the command for npm is: npx

Parameters

ParameterType
packageManagerPackageManager

Returns

string

Defined in

functions/packageManager.ts:86


getPackageManagerForProject()

function getPackageManagerForProject(packageRoot): PackageManager

Helper function to look at the lock files in a given directory in order to detect the package manager being used for the project.

Since 2 or more different kinds of lock files can exist, this will throw an error if 0 lock files are found or if 2 or more lock files are found.

Parameters

ParameterType
packageRootstring

Returns

PackageManager

Defined in

functions/packageManager.ts:99


getPackageManagerInstallCICommand()

function getPackageManagerInstallCICommand(packageManager): string

Helper function to get the continuous integration install command for a package manager. For example, the command for npm is: npm ci

Parameters

ParameterType
packageManagerPackageManager

Returns

string

Defined in

functions/packageManager.ts:124


getPackageManagerInstallCommand()

function getPackageManagerInstallCommand(packageManager): string

Helper function to get the install command for a package manager. For example, the command for npm is: npm install

Parameters

ParameterType
packageManagerPackageManager

Returns

string

Defined in

functions/packageManager.ts:134


getPackageManagerLockFileName()

function getPackageManagerLockFileName(packageManager): string

Helper function to get the corresponding lock file name for a package manager. For example, the package lock file for npm is "package-lock.json".

Parameters

ParameterType
packageManagerPackageManager

Returns

string

Defined in

functions/packageManager.ts:144


getPackageManagersForProject()

function getPackageManagersForProject(packageDir): readonly PackageManager[]

Helper function to look at the lock files in a given directory in order to detect the package manager being used for the project.

Since 2 or more different kinds of lock files can exist, this will return an array containing all of the package managers found. If no lock files were found, this will return an empty array.

Parameters

ParameterType
packageDirstring

Returns

readonly PackageManager[]

Defined in

functions/packageManager.ts:157