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

rui-filedisplay

v1.0.0

Published

演示流程:

Readme

演示流程:

  • (index.js) => 递归显示目录下的文件信息:读取当前命令下的目录

  • (index2.js) => 可接受参数:通过 process 获取参数,遍历参数所指定的目录下的文件,没指定参数就使用当前目录

  • (index3.js) => 可接收可选项:--recursive 或 -r

    • 可能传入多个参数,接受参数需要过滤,是不是可选项,因为有可能 -r 作为第一个参数传入导致错误

    • 对于布尔值的可选项,判断存在即可为 true,因为通过命令行传入的值,都是 true,即使传递 false 也会作为字符串 'false'

    • 使用数组的 includes 判断存在即可为 true

    • 判断目录存在变成了组合可能,不能直接 else 作为文件来处理

  • 改成 CLI 方式:

    • 复制 index3.js 重命名为 index4.js

    • 在 index4.js 加上 node 命令文件声明,还要为该文件赋予可执行权限,执行 JS 文件并传入参数 (./index4.js -r ./)

  • 改成全局 CLI

    • 通过 PATH 实现

      • 复制 index4.js 重命名为 display,通过 PATH 环境变量将文件所在目录添加到 PATH 中 (推荐临时导入,只在当前 Shell 生效,这样不会污染环境变量)
    • 通过 package.json 的 bin 属性实现

      • 初始化为 node 项目

      • 修改 package.json 的 bin 属性,定义一个 display 命令,值是 ./display

      • 运行 npm link,之后便可以在任何地方使用 display 命令了

      • 在项目下运行 npm unlink 前,该命令都是永久生效的,测试完成记得 unlink,不要污染全局变量

  • 发布这个包,然后在其他目录,下载下来,使用 npx 测试