Files
pnpm/shell/path/src/index.ts
Zoltan Kochan f47ef4b125 refactor: reorganize monorepo domain structure (#10987)
Reorganize the monorepo's top-level domain directories for clarity:

- pkg-manager/ split into:
  - installing/ (core, headless, client, resolve-dependencies, etc.)
  - installing/linking/ (hoist, direct-dep-linker, modules-cleaner, etc.)
  - bins/ (link-bins, package-bins, remove-bins)
- completion/ merged into cli/
- dedupe/ moved to installing/dedupe/
- env/ renamed to engine/ with subdomains:
  - engine/runtime/ (node.fetcher, node.resolver, plugin-commands-env, etc.)
  - engine/pm/ (plugin-commands-setup, plugin-commands-self-updater)
- env.path moved to shell/
- tools/ and runtime/ dissolved
- reviewing/ and lockfile audit packages moved to deps/:
  - deps/inspection/ (list, outdated, dependencies-hierarchy)
  - deps/compliance/ (audit, licenses, sbom)
- registry/ moved to resolving/registry/
- semver/peer-range moved to deps/
- network/fetching-types moved to fetching/
- packages/ slimmed down, moving packages to proper domains:
  - calc-dep-state, dependency-path -> deps/
  - parse-wanted-dependency -> resolving/
  - git-utils -> network/
  - naming-cases -> text/
  - make-dedicated-lockfile -> lockfile/
  - render-peer-issues -> installing/
  - plugin-commands-doctor -> cli/
  - plugin-commands-init -> workspace/

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 13:45:54 +01:00

30 lines
680 B
TypeScript

import path from 'node:path'
import PATH from 'path-name'
export interface PrependDirsToPathResult {
name: string
value: string
updated: boolean
}
export function prependDirsToPath (prependDirs: string[], env = process.env): PrependDirsToPathResult {
const prepend = prependDirs.join(path.delimiter)
const envPath = env[PATH]
if (envPath != null && (envPath === prepend || envPath.startsWith(`${prepend}${path.delimiter}`))) {
return {
name: PATH,
value: envPath,
updated: false,
}
}
return {
name: PATH,
value: [
prepend,
...(envPath != null ? [envPath] : []),
].join(path.delimiter),
updated: true,
}
}