UNPKG

sf-decomposer

Version:

Decompose Salesforce metadata into granular, VCS-friendly files; recompose for deployment.

26 lines 979 B
'use strict'; import { access } from 'node:fs/promises'; import { dirname, join } from 'node:path'; import { SFDX_PROJECT_FILE_NAME } from '../../helpers/constants.js'; async function findRepoRoot(dir) { const filePath = join(dir, SFDX_PROJECT_FILE_NAME); try { // Check if sfdx-project.json exists in the current directory await access(filePath); return { repoRoot: dir, dxConfigFilePath: filePath }; } catch (err) { const parentDir = dirname(dir); if (dir === parentDir) { // Reached the root without finding the file, throw an error throw new Error(`${SFDX_PROJECT_FILE_NAME} not found in any parent directory.`, { cause: err }); } // Recursively search in the parent directory return findRepoRoot(parentDir); } } export async function getRepoRoot() { const currentDir = process.cwd(); return findRepoRoot(currentDir); } //# sourceMappingURL=getRepoRoot.js.map