@choojs/findup

中文文档
0.2.1发布于 2018/06/01MITCommonJS近 30 天下载 357.4万

通过走上目录树查找文件

中文使用文档
文档目录5 节
  1. 安装
  2. 使用量
  3. 选项
  4. 麻省理工学院
  5. 阅读测试:)

build status @choojs/发现

这是叉子 Filirom1/ 发现待定 16号。 。 。 .

安装

npm install -g @choojs/findup

使用量

在祖先的目录中查找文件

.
├── config.json
└── f
    └── e
        └── d
            └── c
                ├── b
                │   └── a
                └── config.json

选项

  • maxdepth: (数目, 默认-1) 放弃前要穿越多远 如果最大深度为 -1,则没有限制.

自动同步

查找( dir, 文件Name, 选项, 回调) 查找( dir, 转发器, 选项, 回调) iterator(dir, cb) 仅接受 cb true 或者说 false

var findup = require('@choojs/findup');


findup(__dirname + '/f/e/d/c/b/a', 'config.json', function(err, dir){
  // if(e) e === new Error('not found')
  // dir === '/f/e/d/c'
});

或者说

findup(__dirname + '/f/e/d/c/b/a', function(dir, cb){
  require('path').exists(dir + '/config.json', cb);
}, function(err, dir){
  // if(e) e === new Error('not found')
  // dir === '/f/e/d/c'
});

事件编辑器

查找( dir, 文件Name, 选项)

var findup = require('@choojs/findup');
var fup = findup(__dirname + '/f/e/d/c/b/a', 'config.json');

查找( dir, 转发器, 选项) iterator(dir, cb) 仅接受 cb true 或者说 false

var findup = require('@choojs/findup');
var fup = findup(__dirname + '/f/e/d/c/b/a', function(dir, cb){
  require('path').exists(dir + '/config.json', cb);
});

找到返回事件Emiter。 发布3个事件: found, (中文(简体) ), error, (中文(简体) ), end

found 每次找到文件时都会发出事件.

你可以打个电话来阻止这段旅程 stop 手动.

fup.on('found', function(dir){
  // dir === '/f/e/d/c'
  fup.stop();
});

error 出错时会释放事件

fup.on('error', function(e){
  // if(e) e === new Error('not found')
});

end 事件在翻转结束时或之后释放 stop() 实值 电话.

fup.on('end', function(){
  // happy end
});

同步

查找( dir, 文件Name 查找( dir, 转发器Sync) 与 iteratorSync 返回时 true 或者说 false

var findup = require('@choojs/findup');

try{
  var dir = findup.sync(__dirname + '/f/e/d/c/b/a', 'config.json'); // dir === '/f/e/d/c'
}catch(e){
  // if(e) e === new Error('not found')
}

国 际

npm install -g @choojs/findup

$ cd test/fixture/f/e/d/c/b/a/
$ findup package.json
/root/findup/package.json

使用量

$ findup -h

Usage: findup [FILE]

    --name, -n       The name of the file to found
    --dir, -d        The directoy where we will start walking up    $PWD
    --help, -h       show usage                                     false
    --verbose, -v    print log                                      false

麻省理工学院

阅读测试:)

版本与发布记录

@choojs/findup 共发布 2 个版本,首次发布于 2018/04/11;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.2.1latest2018/06/018 年前
0.2.02018/04/118 年前

关于 @choojs/findup 的常见问题

@choojs/findup 是什么?

通过走上目录树查找文件

如何安装 @choojs/findup?

在项目目录运行 npm install @choojs/findup,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 findup,可以用 npx findup 直接运行。

@choojs/findup 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/choojs__findup 是否存在。

@choojs/findup 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@choojs/findup 可以商用吗?

@choojs/findup 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@choojs/findup 的下载量有多少?

根据 npm 官方下载统计,@choojs/findup 在 2026/10/10 – 2026/11/08 这 30 天内被下载 3,574,307 次,日均约 119,144 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@choojs/findup 还在维护吗?

最新版本 0.2.1 发布于 2018/06/01(8 年前);至今共发布 2 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/04/11。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。