workspace-root
Version:
A simple utility to get the workspace root
47 lines (43 loc) • 1.57 kB
JavaScript
import { lernaWorkspaceRootSync, lernaWorkspaceRoot } from '@node-kit/lerna-workspace-root';
import { pnpmWorkspaceRootSync, pnpmWorkspaceRoot } from '@node-kit/pnpm-workspace-root';
import { yarnWorkspaceRootSync, yarnWorkspaceRoot } from '@node-kit/yarn-workspace-root';
function asyncGeneratorStep(n, t, e, r, o, a, c) {
try {
var i = n[a](c),
u = i.value;
} catch (n) {
return void e(n);
}
i.done ? t(u) : Promise.resolve(u).then(r, o);
}
function _asyncToGenerator(n) {
return function () {
var t = this,
e = arguments;
return new Promise(function (r, o) {
var a = n.apply(t, e);
function _next(n) {
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
}
function _throw(n) {
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
}
_next(void 0);
});
};
}
function workspaceRoot() {
return _workspaceRoot.apply(this, arguments);
}
function _workspaceRoot() {
_workspaceRoot = _asyncToGenerator(function* () {
var cwd = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : process.cwd();
return (yield pnpmWorkspaceRoot(cwd)) || (yield yarnWorkspaceRoot(cwd)) || (yield lernaWorkspaceRoot(cwd)) || null;
});
return _workspaceRoot.apply(this, arguments);
}
function workspaceRootSync() {
var cwd = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : process.cwd();
return pnpmWorkspaceRootSync(cwd) || yarnWorkspaceRootSync(cwd) || lernaWorkspaceRootSync(cwd) || null;
}
export { workspaceRoot, workspaceRootSync };