mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: add JSDocs
This commit is contained in:
@@ -2,6 +2,12 @@ import { getPackageJson, getProjectRootPath } from './project';
|
||||
import path from 'path';
|
||||
|
||||
// todo: memoize
|
||||
/**
|
||||
* Utility to get all dependencies from the project package.json.
|
||||
* The result combines dependencies and devDependencies
|
||||
*
|
||||
* @returns string[] dependencies
|
||||
*/
|
||||
export function getAllDependencies(): string[] {
|
||||
const packageJSON = getPackageJson();
|
||||
|
||||
@@ -12,11 +18,23 @@ export function getAllDependencies(): string[] {
|
||||
}
|
||||
|
||||
// todo: memoize
|
||||
/**
|
||||
* Utility to check if the project has a specific dependency
|
||||
* in either dependencies or devDependencies.
|
||||
*
|
||||
* @param {string} dependencyName
|
||||
* @returns boolean
|
||||
*/
|
||||
export function hasDependency(dependencyName: string) {
|
||||
return getAllDependencies().includes(dependencyName);
|
||||
}
|
||||
|
||||
// todo: memoize
|
||||
/**
|
||||
* Utility to get the path (usually nested in node_modules) of a dependency.
|
||||
*
|
||||
* @param dependencyName
|
||||
*/
|
||||
export function getDependencyPath(dependencyName: string): string | null {
|
||||
try {
|
||||
const resolvedPath = require.resolve(`${dependencyName}/package.json`, {
|
||||
|
||||
Reference in New Issue
Block a user