@ms-cloudpack/path-utilities
Advanced tools
Comparing version 2.0.2 to 2.1.0
/** | ||
* Given an absolute folder path into a package, traverse up the paths | ||
* until the root has been found (containing the package.json file.) | ||
* until the root has been found (containing the package.json file). | ||
* Returns undefined if no package root is found after traversing to the filesystem root. | ||
*/ | ||
export declare function findPackageRoot(currentPath: string): string; | ||
export declare function findPackageRoot(currentPath: string): string | undefined; |
@@ -5,6 +5,11 @@ import fs from 'fs'; | ||
* Given an absolute folder path into a package, traverse up the paths | ||
* until the root has been found (containing the package.json file.) | ||
* until the root has been found (containing the package.json file). | ||
* Returns undefined if no package root is found after traversing to the filesystem root. | ||
*/ | ||
export function findPackageRoot(currentPath) { | ||
while (currentPath && !fs.existsSync(path.join(currentPath, 'package.json'))) { | ||
const root = path.parse(currentPath).root; | ||
while (!fs.existsSync(path.join(currentPath, 'package.json'))) { | ||
if (currentPath === root) { | ||
return undefined; | ||
} | ||
currentPath = path.join(currentPath, '..'); | ||
@@ -11,0 +16,0 @@ } |
{ | ||
"name": "@ms-cloudpack/path-utilities", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"description": "Utilities for resolving paths between source/intermediate/output locations in Cloudpack.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15018
193