Skip to main content

Package Manager

Helper functions for JavaScript/TypeScript package managers.

Functions

getPackageManagerAddCommand()

function getPackageManagerAddCommand(packageManager, dependency): string;

Defined in: packages/complete-node/src/functions/packageManager.ts:43

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


getPackageManagerAddDevCommand()

function getPackageManagerAddDevCommand(packageManager, dependency): string;

Defined in: packages/complete-node/src/functions/packageManager.ts:70

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


getPackageManagerExecCommand()

function getPackageManagerExecCommand(packageManager): string;

Defined in: packages/complete-node/src/functions/packageManager.ts:97

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

Parameters

ParameterType
packageManagerPackageManager

Returns

string


getPackageManagerForProject()

function getPackageManagerForProject(packageRoot): Promise<
| undefined
| PackageManager>;

Defined in: packages/complete-node/src/functions/packageManager.ts:109

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

Parameters

ParameterType
packageRootstring

Returns

Promise< | undefined | PackageManager>

Throws

If two or more lock files were found.


getPackageManagerInstallCICommand()

function getPackageManagerInstallCICommand(packageManager): string;

Defined in: packages/complete-node/src/functions/packageManager.ts:136

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


getPackageManagerInstallCommand()

function getPackageManagerInstallCommand(packageManager): string;

Defined in: packages/complete-node/src/functions/packageManager.ts:146

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


getPackageManagerLockFileName()

function getPackageManagerLockFileName(packageManager): string;

Defined in: packages/complete-node/src/functions/packageManager.ts:156

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


getPackageManagerLockFileNames()

function getPackageManagerLockFileNames(): readonly string[];

Defined in: packages/complete-node/src/functions/packageManager.ts:163

Helper function to get an array containing every package manager lock file name.

Returns

readonly string[]


getPackageManagersForProject()

function getPackageManagersForProject(packageDir): Promise<readonly PackageManager[]>;

Defined in: packages/complete-node/src/functions/packageManager.ts:174

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

Promise<readonly PackageManager[]>