npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@yarn-tool/path-parents

v2.0.23

Published

列出從當前目錄向上搜尋至工作區根目錄的路徑列表。List paths from the current directory up to the workspace root.

Readme

@yarn-tool/path-parents

列出從當前目錄一路向上至工作區根目錄的所有父層路徑。 List all parent paths from the current directory up to the workspace root.

安裝 / Install

yarn add @yarn-tool/path-parents
yarn-tool add @yarn-tool/path-parents
yt add @yarn-tool/path-parents

使用方法 / Usage

import pathUpToWorkspaces, { pathUpToWorkspacesGenerator } from '@yarn-tool/path-parents';

// 取得路徑陣列(包含當前目錄) / Get path list (including current directory)
const list = pathUpToWorkspaces(process.cwd());
// => ["/repo/packages/a", "/repo/packages", "/repo", ...]

// 使用產生器逐一遍歷 / Iterate one by one using generator
for (const p of pathUpToWorkspacesGenerator(process.cwd())) {
  console.log(p);
}

API

  • pathUpToWorkspaces(cwd?: string, options?: IOptions): string[]

    • 回傳從 cwd 開始往上直到偵測到的工作區根目錄之所有路徑(含或不含 cwd 取決於選項)。
    • Returns all parent paths from cwd up to the detected workspace root (including or excluding cwd based on options).
  • pathUpToWorkspacesGenerator(cwd?: string, options?: IOptions): Generator<string>

    • 以產生器逐一回傳路徑,直到抵達工作區根目錄為止。
    • Yields paths one by one until the workspace root is reached.

IOptions

  • ignoreCurrentDirectory?: boolean
    • 預設為 false。若為 true,結果將不包含 cwd 本身。
    • Defaults to false. If true, the result will exclude the cwd itself.

備註 / Notes

  • 使用 @yarn-tool/find-root 偵測是否位於 Yarn/NPM/Pnpm 工作區,並在達到該根目錄時停止。
  • Uses @yarn-tool/find-root to detect the Yarn/NPM/Pnpm workspace root and stops at that directory.