{"name":"@yarn-tool/get-paths-by-type","version":"2.0.21","keywords":["yarn-tool","get-paths","global-dirs","global-paths","symbol","path-resolver","npm-global","yarn-global","yarn","npm","workspaces","monorepo","node-modules","packages","package"],"author":{"name":"bluelovers"},"license":"ISC","_id":"@yarn-tool/get-paths-by-type@2.0.21","maintainers":[{"name":"bluelovers","email":"codelovers@users.sourceforge.net"}],"homepage":"https://github.com/bluelovers/ws-yarn-workspaces/tree/master/packages/@yarn-tool/get-paths-by-type#readme","bugs":{"url":"https://github.com/bluelovers/ws-yarn-workspaces/issues"},"dist":{"shasum":"980a2504e780b9cfb6d3c1b76f61f97fa44a45ef","tarball":"http://registry-npm.ywwl.com/@yarn-tool/get-paths-by-type/download/@yarn-tool/get-paths-by-type-2.0.21.tgz","fileCount":6,"integrity":"sha512-tQ3b+L+I9K7QmjXQxubXpbvl872FFYeINHiu5AFbxPXZ/5tnlZf4SreP3RL6qwyB1Fm8KOluE+tANYM5i+lf5A==","signatures":[{"sig":"MEYCIQDRLnlb20EE6rWTbEqS23CuxYH73mQaF9ZsOkpNqfl1owIhANjJlMGH4CtLjxrx1jiSWnv4wF/YANtJHbs2FrQifslX","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEQCIHoUJVr+Q28JW+hdEhQp4RAkgtv9pf0O+YEuxxJfbAviAiAjciA8hN9BsqthkMRiyNAtRreG7/2RNGK1xGs+ebn03w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":44556,"size":11480,"noattachment":false,"key":"/@yarn-tool/get-paths-by-type/-/@yarn-tool/get-paths-by-type-2.0.21.tgz"},"main":"index.js","types":"./index.d.ts","gitHead":"cf2f309300d7e01680c5b8bd91114fe16dbadb24","scripts":{"ncu":"yarn-tool ncu -u","lint":"ynpx --quiet eslint -- **/*.ts","test":"node --run test:node","coverage":"pnpm run test -- --coverage","test:tsc":"tsc --noEmit & echo typescript check done","test:tsd":"ynpx tsd","test:jest":"jest --passWithNoTests","test:node":"tsx --test --test-update-snapshots **/*.node-spec.ts **/*.node-test.ts **/*.spec.ts **/*.test.ts","preversion":"echo preversion && pnpm run test","test:mocha":"ynpx --quiet -p ts-node -p mocha mocha -- --require ts-node/register \"!(node_modules)/**/*.{test,spec}.{ts,tsx}\"","test:snapshot":"pnpm run test -u","tsc:showConfig":"ynpx get-current-tsconfig -p","sort-package-json":"yarn-tool sort","test:jest:coverage":"pnpm run test:jest -- --coverage","test:jest:snapshot":"pnpm run test:jest -- -u","prepublishOnly:update":"pnpm run ncu && pnpm run sort-package-json"},"_npmUser":{"name":"bluelovers","email":"codelovers@users.sourceforge.net"},"repository":{"url":"git+https://github.com/bluelovers/ws-yarn-workspaces.git","type":"git","directory":"packages/@yarn-tool/get-paths-by-type"},"_npmVersion":"lerna/7.4.2/node@v26.7.0+x64 (win32)","description":"根據類型 Symbol 取得對應的路徑陣列（支援全域 npm/yarn 路徑） / Get corresponding path array based on type Symbol (supports global npm/yarn paths)","directories":{},"_nodeVersion":"26.7.0","dependencies":{"tslib":">=2.8.1","@yarn-tool/fnm-detect":"^1.0.10","@yarn-tool/get-global-dirs":"^1.0.8"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/get-paths-by-type_2.0.21_1791824703240_0.24915504668909483","host":"s3://npm-registry-packages-npm-production"},"readme":"# @yarn-tool/get-paths-by-type\n\n根據類型 Symbol 取得對應的路徑陣列（支援全域 npm/yarn 路徑、當前目錄、主模組路徑）。  \nGet corresponding path array based on type Symbol (supports global npm/yarn paths, current directory, and main module path).\n\n## 功能特色 (Features)\n\n- 🧭 **Symbol 分派 (Symbol Dispatch)** - 以全域註冊的 Symbol（`Symbol.for(...)`）選擇路徑類型，避免字串比對的拼寫錯誤\n- 🌐 **全域路徑 (Global Paths)** - 支援 Npm、Yarn、Pnpm 的全域套件目錄，並自動偵測 fnm 安裝路徑\n- 📂 **多種類型 (Multiple Types)** - 涵蓋當前工作目錄 (Current Working Directory)、全域目錄與主模組 (Main Module) 路徑\n- 🧰 **彈性輸入 (Flexible Input)** - `getPathsByTypeLazy` 接受單一 Symbol、字串或其陣列，一次取得多組路徑\n\n## 安裝 (Installation)\n\n```bash\n# 使用 yarn / Using yarn\nyarn add @yarn-tool/get-paths-by-type\n\n# 使用 yarn-tool / Using yarn-tool\nyarn-tool add @yarn-tool/get-paths-by-type\n# yt 是 yarn-tool 的別名 / yt is an alias for yarn-tool\nyt add @yarn-tool/get-paths-by-type\n\n# 使用 pnpm / Using pnpm\npnpm add @yarn-tool/get-paths-by-type\n\n# 使用 npm / Using npm\nnpm install @yarn-tool/get-paths-by-type\n```\n\n## 使用範例 (Usage Example)\n\n```typescript\nimport getPathsByType, {\n  SymbolCurrentDirectory,\n  SymbolGlobal,\n  SymbolGlobalNpm,\n  SymbolGlobalYarn,\n  SymbolModuleMain,\n} from '@yarn-tool/get-paths-by-type';\n\n// 取得全域 Yarn 套件目錄 / Get global Yarn package directory\nconst yarnPaths = getPathsByType(SymbolGlobalYarn);\nconsole.log(yarnPaths); // ['/usr/local/share/.config/yarn/global/node_modules']\n\n// 取得全域 Npm 套件目錄 / Get global Npm package directory\nconst npmPaths = getPathsByType(SymbolGlobalNpm);\nconsole.log(npmPaths); // ['/usr/local/lib/node_modules']\n\n// 取得所有全域路徑（Yarn + Npm）/ Get all global paths (Yarn + Npm)\nconst globalPaths = getPathsByType(SymbolGlobal);\nconsole.log(globalPaths); // [yarn packages path, npm packages path]\n\n// 取得當前工作目錄 / Get current working directory\nconst cwdPaths = getPathsByType(SymbolCurrentDirectory);\nconsole.log(cwdPaths); // [process.cwd()]\n\n// 取得當前目錄（指定路徑）/ Get current directory (specified path)\nconst customCwdPaths = getPathsByType(SymbolCurrentDirectory, '/custom/path');\n\n// 取得主模組路徑 / Get main module path\nconst mainModulePaths = getPathsByType(SymbolModuleMain);\n```\n\n## API 文件 / API Documentation\n\n### `getPathsByType(valueType, cwd?)`\n\n根據類型 Symbol 取得對應的路徑陣列。\n\n**參數 (Parameters):**\n- `valueType` - 路徑類型 Symbol / Path type Symbol\n- `cwd` - 工作目錄（選填，用於 SymbolCurrentDirectory）/ Working directory (optional, for SymbolCurrentDirectory)\n\n**返回 (Returns):** `string[]` - 路徑陣列 / Path array\n\n### `getPathsByTypeLazy(valueType, cwd?)`\n\n接受單一 Symbol、字串或兩者混合的陣列，逐一解析並合併結果；字串為空時拋出 `TypeError`。  \nAccepts a single Symbol, a string, or an array mixing both, resolving and merging the results; throws `TypeError` for an empty string.\n\n**參數 (Parameters):**\n- `valueType` - 路徑類型 Symbol、路徑字串或其陣列 / Path type Symbol, path string, or an array of them\n- `cwd` - 工作目錄（選填，用於 SymbolCurrentDirectory）/ Working directory (optional, for SymbolCurrentDirectory)\n\n**返回 (Returns):** `string[]` - 合併後的路徑陣列 / Merged path array\n\n### `isValidPathSymbol(value)`\n\n判斷給定值是否為本模組支援的路徑類型 Symbol。  \nChecks whether the given value is a supported path type Symbol.\n\n### Symbol 類型 (Symbol Types)\n\n| Symbol | 說明 / Description |\n|--------|-------------------|\n| `SymbolCurrentDirectory` | 當前工作目錄 / Current working directory |\n| `SymbolGlobal` | 全域 Yarn + Npm 套件目錄 / Global Yarn + Npm package directories |\n| `SymbolGlobalNpm` | 全域 Npm 套件目錄 / Global Npm package directory |\n| `SymbolGlobalYarn` | 全域 Yarn 套件目錄 / Global Yarn package directory |\n| `SymbolGlobalPnpm` | 全域 Pnpm 套件目錄 / Global Pnpm package directory |\n| `SymbolModuleMain` | 主模組的路徑 / Main module path |\n\n## 設定 / Configuration\n\n本模組無須額外設定檔，行為由傳入的參數與執行環境決定：\nThis module requires no extra configuration file; behavior is determined by the passed arguments and the runtime environment:\n\n- `cwd` 參數 - 僅影響 `SymbolCurrentDirectory`；未傳入時使用 `process.cwd()` /\n  Affects `SymbolCurrentDirectory` only; falls back to `process.cwd()` when omitted\n- 全域路徑（`SymbolGlobalNpm`、`SymbolGlobalYarn`、`SymbolGlobalPnpm`、`SymbolGlobal`）- 依 npm/yarn/pnpm 的全域安裝位置而定，並在偵測到 fnm 時額外加入其 `node_modules` 路徑 /\n  Global paths depend on the global install locations of npm/yarn/pnpm; when fnm is detected, its `node_modules` path is also included\n- `SymbolModuleMain` - 依目前 Node.js 程序的主模組 (Main Module) 而定 /\n  Depends on the main module of the current Node.js process\n\n## License\n\nISC","publish_time":1791824703330,"_cnpm_publish_time":1791824703330,"dist-tags":{"latest":"2.0.26"}}