workspace-tools
Version:
A collection of utilities that are useful in a git-controlled monorepo managed by one of these tools:
45 lines • 2.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getWorkspacesAsync = exports.getWorkspaces = exports.getNpmWorkspacesAsync = exports.getNpmWorkspaces = exports.getWorkspacePackagePathsAsync = exports.getWorkspacePackagePaths = void 0;
const _1 = require(".");
const packageJsonWorkspaces_1 = require("./packageJsonWorkspaces");
function getNpmWorkspaceRoot(cwd) {
const root = (0, _1.getWorkspaceManagerAndRoot)(cwd, undefined, "npm")?.root;
if (!root) {
throw new Error("Could not find npm workspace root from " + cwd);
}
return root;
}
/** Get paths for each package ("workspace") in an npm monorepo. */
function getWorkspacePackagePaths(cwd) {
const npmWorkspacesRoot = getNpmWorkspaceRoot(cwd);
return (0, packageJsonWorkspaces_1.getPackagePathsFromWorkspaceRoot)(npmWorkspacesRoot);
}
exports.getWorkspacePackagePaths = getWorkspacePackagePaths;
/** Get paths for each package ("workspace") in an npm monorepo. */
function getWorkspacePackagePathsAsync(cwd) {
const npmWorkspacesRoot = getNpmWorkspaceRoot(cwd);
return (0, packageJsonWorkspaces_1.getPackagePathsFromWorkspaceRootAsync)(npmWorkspacesRoot);
}
exports.getWorkspacePackagePathsAsync = getWorkspacePackagePathsAsync;
/**
* Get an array with names, paths, and package.json contents for each package ("workspace")
* in an npm monorepo.
*/
function getNpmWorkspaces(cwd) {
const npmWorkspacesRoot = getNpmWorkspaceRoot(cwd);
return (0, packageJsonWorkspaces_1.getWorkspaceInfoFromWorkspaceRoot)(npmWorkspacesRoot);
}
exports.getNpmWorkspaces = getNpmWorkspaces;
exports.getWorkspaces = getNpmWorkspaces;
/**
* Get an array with names, paths, and package.json contents for each package ("workspace")
* in an npm monorepo.
*/
function getNpmWorkspacesAsync(cwd) {
const npmWorkspacesRoot = getNpmWorkspaceRoot(cwd);
return (0, packageJsonWorkspaces_1.getWorkspaceInfoFromWorkspaceRootAsync)(npmWorkspacesRoot);
}
exports.getNpmWorkspacesAsync = getNpmWorkspacesAsync;
exports.getWorkspacesAsync = getNpmWorkspacesAsync;
//# sourceMappingURL=npm.js.map