UNPKG

@salesforce/core

Version:

Core libraries to interact with SFDX projects, orgs, and APIs.

59 lines 2.21 kB
"use strict"; /* * Copyright (c) 2020, salesforce.com, inc. * All rights reserved. * Licensed under the BSD 3-Clause license. * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ Object.defineProperty(exports, "__esModule", { value: true }); exports.resolveProjectPathSync = exports.resolveProjectPath = exports.SFDX_PROJECT_JSON = void 0; const sfdxError_1 = require("../sfdxError"); const fs_1 = require("./fs"); /** * The name of the project config file. * * @ignore */ // This has to be defined on util to prevent circular deps with project and configFile. exports.SFDX_PROJECT_JSON = 'sfdx-project.json'; /** * Performs an upward directory search for an sfdx project file. Returns the absolute path to the project. * * **See** {@link SFDX_PROJECT_JSON} * * **See** {@link traverseForFile} * * **Throws** *{@link SfdxError}{ name: 'InvalidProjectWorkspace' }* If the current folder is not located in a workspace. * * @param dir The directory path to start traversing from. * @ignore */ async function resolveProjectPath(dir = process.cwd()) { const projectPath = await fs_1.fs.traverseForFile(dir, exports.SFDX_PROJECT_JSON); if (!projectPath) { throw sfdxError_1.SfdxError.create('@salesforce/core', 'config', 'InvalidProjectWorkspace'); } return projectPath; } exports.resolveProjectPath = resolveProjectPath; /** * Performs a synchronous upward directory search for an sfdx project file. Returns the absolute path to the project. * * **See** {@link SFDX_PROJECT_JSON} * * **See** {@link traverseForFile} * * **Throws** *{@link SfdxError}{ name: 'InvalidProjectWorkspace' }* If the current folder is not located in a workspace. * * @param dir The directory path to start traversing from. * @ignore */ function resolveProjectPathSync(dir = process.cwd()) { const projectPath = fs_1.fs.traverseForFileSync(dir, exports.SFDX_PROJECT_JSON); if (!projectPath) { throw sfdxError_1.SfdxError.create('@salesforce/core', 'config', 'InvalidProjectWorkspace'); } return projectPath; } exports.resolveProjectPathSync = resolveProjectPathSync; //# sourceMappingURL=internal.js.map