Skip to main content

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

ParameterType
packageManagerPackageManager
dependencystring

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

ParameterType
packageManagerPackageManager
dependencystring

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

ParameterType
packageManagerPackageManager

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

ParameterType
packageRootstring

Returns

PackageManager

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

ParameterType
packageManagerPackageManager

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

ParameterType
packageManagerPackageManager

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

ParameterType
packageManagerPackageManager

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

ParameterType
packageDirstring

Returns

readonly PackageManager[]

Defined in

packages/complete-node/src/functions/packageManager.ts:168