Package Manager
Helper functions for JavaScript/TypeScript package managers.
Functions
getPackageManagerAddCommand()
function getPackageManagerAddCommand(packageManager, dependency): string
Defined in: functions/packageManager.ts:39
Helper function to get the add command for a package manager. For example, the command for npm
is: npm install foo --save
Parameters
Parameter | Type |
---|---|
packageManager | PackageManager |
dependency | string |
Returns
string
getPackageManagerAddDevCommand()
function getPackageManagerAddDevCommand(packageManager, dependency): string
Defined in: functions/packageManager.ts:66
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
Parameter | Type |
---|---|
packageManager | PackageManager |
dependency | string |
Returns
string
getPackageManagerExecCommand()
function getPackageManagerExecCommand(packageManager): string
Defined in: functions/packageManager.ts:93
Helper function to get the exec command for a package manager. For example, the command for npm
is: npx
Parameters
Parameter | Type |
---|---|
packageManager | PackageManager |
Returns
string
getPackageManagerForProject()
function getPackageManagerForProject(packageRoot): PackageManager
Defined in: functions/packageManager.ts:106
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
Parameter | Type |
---|---|
packageRoot | string |
Returns
getPackageManagerInstallCICommand()
function getPackageManagerInstallCICommand(packageManager): string
Defined in: functions/packageManager.ts:131
Helper function to get the continuous integration install command for a package manager. For
example, the command for npm is: npm ci
Parameters
Parameter | Type |
---|---|
packageManager | PackageManager |
Returns
string
getPackageManagerInstallCommand()
function getPackageManagerInstallCommand(packageManager): string
Defined in: functions/packageManager.ts:141
Helper function to get the install command for a package manager. For example, the command for
npm is: npm install
Parameters
Parameter | Type |
---|---|
packageManager | PackageManager |
Returns
string
getPackageManagerLockFileName()
function getPackageManagerLockFileName(packageManager): string
Defined in: functions/packageManager.ts:151
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
Parameter | Type |
---|---|
packageManager | PackageManager |
Returns
string
getPackageManagerLockFileNames()
function getPackageManagerLockFileNames(): readonly string[]
Defined in: functions/packageManager.ts:158
Helper function to get an array containing every package manager lock file name.
Returns
readonly string
[]
getPackageManagersForProject()
function getPackageManagersForProject(packageDir): readonly PackageManager[]
Defined in: functions/packageManager.ts:169
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
Parameter | Type |
---|---|
packageDir | string |
Returns
readonly PackageManager
[]