UNPKG

@stryke/path

Version:

A package containing various utilities that expand the functionality of NodeJs's built-in `path` module

26 lines (25 loc) 1.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getWorkspaceRoot = exports.getProjectRoot = void 0; var _configTools = require("@storm-software/config-tools"); var _getParentPath = require("./get-parent-path.cjs"); var _isRootDir = require("./is-root-dir.cjs"); const getWorkspaceRoot = (t = process.cwd()) => { if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) return process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH; const r = (0, _configTools.findWorkspaceRootSafe)(t); if (r) return r; let o = (0, _getParentPath.getParentPath)(["package-lock.json", "yarn.lock", "pnpm-lock.yaml", "bun.lock", "nx.json", "knip.json", "pnpm-workspace.yaml", "LICENSE", ".all-contributorsrc", ".whitesource", "syncpack.config.js", "syncpack.json", "socket.yaml", "lefthook.yaml", ".npmrc", ".log4brains.yml", ".huskyrc", ".husky", ".lintstagedrc", ".commitlintrc", "lefthook.yml", ".github", ".nx", ".vscode", "patches"], t); if (o) return o; for (o = t; o && !(0, _isRootDir.isSystemRoot)(o);) if (o = (0, _getParentPath.getParentPath)("storm.json", o, { skipCwd: !0 }), o) return o; return t; }, getProjectRoot = (t = process.cwd()) => { const r = (0, _getParentPath.getParentPath)(["project.json", "package.json", ".storm"], t); return r || t; }; exports.getProjectRoot = getProjectRoot; exports.getWorkspaceRoot = getWorkspaceRoot;