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 🙏

© 2025 – Pkg Stats / Ryan Hefner

yangester-cli

v1.0.2

Published

```bash //install # npm install -g yangester-cli

Downloads

6

Readme

yangester-cli

打造一个简易的前端开发流

usage
//install
# npm install -g yangester-cli

// delete files
# yang rm example.text exmaple2.json

// delte a directory
# yang rm -rf a

// delete the content of a directory
# yang rm -rf a/*

// copy a file to 'cache' directory

# yang cp example.text cache/

// copy a directory to 'cache' directory
# yang cp a cache/

// create files
# yang touch a.js b.js

// create directories
# yang mkdir a b c

参考

Todo

  • [x] 实现文件的基本操作功能
  • [ ] 实现一个server和cli
关于node.js文件的操作,以及本模块的原理:
如何写入一个文件?

writeMyData就是

fs.writeFile('example.text','utf8', err=>{})

fs.open('myfile', 'wx', (err, fd) => {
  if (err) {
    if (err.code === 'EEXIST') {
      console.error('myfile already exists');
      return;
    }

    throw err;
  }

  writeMyData(fd);
});
如何打开一个文件?

readMyData就是

fs.readFile('example.text','utf8', err=>{})

fs.open('myfile', 'r', (err, fd) => {
  if (err) {
    if (err.code === 'ENOENT') {
      console.error('myfile does not exist');
      return;
    }

    throw err;
  }

  readMyData(fd);
});
如何创建/删除一个文件夹
//创建文件夹b
fs.mkdir('./a/b', err => {})
//创建空文件夹b
fs.rmdir('./a/b', err => {})
如何删除一个文件
//删除文件b
fs.unlink('./a/b.text', err => {})
删除/赋值文件夹

删除以及复制文件夹, 其实思路大致是相同的。我们先定义一个walk函数,用于遍历目标文件夹。这个walk函数返回的是一个Promise实例。

mkdir([path.join(dest, directory)])
        .then(
            () => {
                return readdir(directory)
            }
        )

以复制文件夹a 到 目标目录 ./dest 为例子, 首先我们先在./dest下创建一个空目录a,然后调用readdir遍历a目录,如果a非空的话,返回的是一个files数组,调用数组的map方法,对每一个file,return一个fsstats。最后被包裹在Promise.all里面,然后返回这个Promise.all。

.then(files => {
            return Promise.all(
                files.map( f =>{
                    f = path.join(directory, f)
                    return fstatSync(f)
                })
            )
        })

接下来,如果判断是个文件夹,那么再walk一遍,并return(此时又在dest下创建了一个新目录)。如果是个文件,直接复制到dest的相应路径里。

.then(
            fileStats => {
                return Promise.all(
                    fileStats.map(fileStat => {
                        if (fileStat.isDirectory()) {    
                            return walk(fileStat.dir, dest)
                        } else {
                            copyDirectory(fileStat.dir, dest)
                        }
                    }))
            }
        ).catch(e => {
            console.log(e)
        })