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/ws-find-up-paths

v1.0.19

Published

在工作區環境中向上搜尋檔案或目錄的工具 (Find files or directories by walking up parent directories in workspace environments)

Downloads

423

Readme

@yarn-tool/ws-find-up-paths

在工作區環境中向上搜尋檔案或目錄的工具
Find files or directories by walking up parent directories in workspace environments

簡介 / Introduction

此模組結合 find-up-paths 與 yarn workspaces 功能,提供在工作區環境中向上搜尋檔案或目錄的能力。它會自動偵測工作區根目錄,並限制搜尋範圍不超過工作區邊界。

This module combines find-up-paths with yarn workspaces functionality, providing the ability to search upward for files or directories in a workspace environment. It automatically detects the workspace root and limits the search scope within workspace boundaries.

功能特色 / Features

  • 🔄 工作區感知 (Workspace-aware) - 自動偵測工作區根目錄,限制搜尋範圍
  • 📁 向上搜尋 (Find Up) - 從當前目錄向上遍歷父層目錄
  • 同步/非同步支援 (Sync/Async Support) - 提供同步與非同步兩種 API
  • 🎯 靈活選項 (Flexible Options) - 支援忽略當前套件或從套件目錄開始搜尋

安裝 / Install

yarn add @yarn-tool/ws-find-up-paths

yarn-tool add @yarn-tool/ws-find-up-paths

yt add @yarn-tool/ws-find-up-paths

pnpm add @yarn-tool/ws-find-up-paths

npm install @yarn-tool/ws-find-up-paths

使用方式 / Usage

基本用法 / Basic Usage

import { findUpPathsWorkspaces } from '@yarn-tool/ws-find-up-paths';

// 搜尋 package.json 檔案
// Search for package.json file
const result = findUpPathsWorkspaces('package.json');
console.log(result);
// { stat: Stats, result: '/path/to/package.json' }

非同步版本 / Async Version

import { findUpPathsWorkspacesAsync } from '@yarn-tool/ws-find-up-paths';

// 非同步搜尋
// Async search
const result = await findUpPathsWorkspacesAsync(['package.json', 'package-lock.json']);
console.log(result);

取得所有父層路徑 / Get All Parent Paths

import { pathParentsWorkspaces } from '@yarn-tool/ws-find-up-paths';

// 取得從當前目錄到工作區根目錄的所有父層路徑
// Get all parent paths from current directory to workspace root
const paths = pathParentsWorkspaces();
console.log(paths);
// ['/path/to/current', '/path/to/parent', '/path/to/workspace-root']

選項說明 / Options

interface IOptionsFindUpPathsWorkspaces {
  /**
   * 是否忽略當前套件目錄
   * Whether to ignore the current package directory
   */
  ignoreCurrentPackage?: boolean;
  
  /**
   * 是否從當前套件目錄開始搜尋
   * Whether to start searching from the current package directory
   */
  startFromCurrentPackage?: boolean;
  
  // 繼承自 find-up-paths 的選項
  // Options inherited from find-up-paths
  cwd?: string;
  includeCurrentDirectory?: boolean;
  stopPath?: string | string[];
  onlyFiles?: boolean;
  onlyDirectories?: boolean;
}

API

findUpPathsWorkspaces(pattern, opts?)

同步搜尋符合條件的檔案或目錄。
Synchronously search for files or directories matching the pattern.

findUpPathsWorkspacesAsync(pattern, opts?)

非同步搜尋符合條件的檔案或目錄。
Asynchronously search for files or directories matching the pattern.

pathParentsWorkspaces(cwd?, opts?)

取得從當前目錄到工作區根目錄的所有父層路徑。
Get all parent paths from current directory to workspace root.

handleOptions(cwd?, opts?)

處理選項並返回執行時期物件。
Process options and return runtime object.

相關模組 / Related Modules

授權 / License

ISC