Package Manager
Helper functions for JavaScript/TypeScript package managers.
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
Parameter | Type |
---|---|
packageManager | PackageManager |
dependency | string |
Returns
string
Defined in
packages/complete-node/src/functions/packageManager.ts:38
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
Parameter | Type |
---|---|
packageManager | PackageManager |
dependency | string |
Returns
string
Defined in
packages/complete-node/src/functions/packageManager.ts:65
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
Parameter | Type |
---|---|
packageManager | PackageManager |
Returns
string
Defined in
packages/complete-node/src/functions/packageManager.ts:92
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
Parameter | Type |
---|---|
packageRoot | string |
Returns
Defined in
packages/complete-node/src/functions/packageManager.ts:105
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
Parameter | Type |
---|---|
packageManager | PackageManager |
Returns
string
Defined in
packages/complete-node/src/functions/packageManager.ts:130
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
Parameter | Type |
---|---|
packageManager | PackageManager |
Returns
string
Defined in
packages/complete-node/src/functions/packageManager.ts:140
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
Parameter | Type |
---|---|
packageManager | PackageManager |
Returns
string
Defined in
packages/complete-node/src/functions/packageManager.ts:150
getPackageManagerLockFileNames()
function getPackageManagerLockFileNames(): readonly string[]
Helper function to get an array containing every package manager lock file name.
Returns
readonly string
[]
Defined in
packages/complete-node/src/functions/packageManager.ts:157
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
Parameter | Type |
---|---|
packageDir | string |
Returns
readonly PackageManager
[]