workspace-tools
Version:
A collection of utilities that are useful in a git-controlled monorepo managed by one of these tools:
34 lines • 1.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getWorkspaceManagerRoot = exports.getWorkspaceRoot = void 0;
const implementations_1 = require("./implementations");
/**
* Get the root directory of a monorepo, defined as the directory where the workspace manager
* config file is located.
*
* NOTE: "Workspace" here refers to the entire project, not an individual package the way it does
* in e.g. npm/yarn/pnpm "workspaces."
*
* @param cwd Start searching from here
* @param preferredManager Search for only this manager's config file
*
* @deprecated Renamed to `getWorkspaceManagerRoot` to align "workspace" terminology with npm/yarn/pnpm.
* In most cases, you should use `findProjectRoot` instead since it falls back to the git root if no
* workspace manager is found (single-package projects).
*/
function getWorkspaceRoot(cwd, preferredManager) {
return getWorkspaceManagerRoot(cwd, preferredManager);
}
exports.getWorkspaceRoot = getWorkspaceRoot;
/**
* Get the root directory of a monorepo, defined as the directory where the workspace manager
* config file is located.
*
* @param cwd Start searching from here
* @param preferredManager Search for only this manager's config file
*/
function getWorkspaceManagerRoot(cwd, preferredManager) {
return (0, implementations_1.getWorkspaceManagerAndRoot)(cwd, undefined, preferredManager)?.root;
}
exports.getWorkspaceManagerRoot = getWorkspaceManagerRoot;
//# sourceMappingURL=getWorkspaceRoot.js.map