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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ljyclear

v0.0.1

Published

clear node_modules

Downloads

11

Readme

ljyclear

说明

在更新一个项目的时候,总是会重新拉取一个分支,然后再把代码download下来。在本地每次都会 npm install 一次,造成我的项目文件夹中总是会有很多重复的 node_modules ,时间长了,这些无用且体积庞大的 node_modules 占用了我巨大的硬盘内存,所以我在node的环境中结合 rimraf 做了一个批次清理的插件。

Installation

$ npm i -g npm
$ npm i ljyclear --save  

repositories

仓库地址 :

https://github.com/ljylhm/ljyTools.git

使用说明


   // 将包引入
   // 1. main是主函数 在主函数中结合了 findModules 和 clear函数
   // 2. findModules是寻找指定模块的函数
   // 3. clear函数是清除的函数 

   const { main, findModules, clear} = require("ljyclear");

   /**
    * @description 主函数
    * @param {String} path 路径
    * @param {String} target 目标路径
    * @param {Object} opts 配置
    * {
    *   filter { String | Array } 过滤条件 
    *   => 过滤的文件夹不会遍历下去 例如node_modules
    *   externals { Array }  数组中的内容不会被删除
    * }
    * @return {Void} 
    */
   main(path,target,opts)

   // 以下代码的意思是删除 D:\\我的项目2这个文件夹中所有的node_modules
   main("D:\\我的项目2", "node_modules", {
      filter: ["node_modules"],
      externals: ["test1 - 副本 (2)", "test1 - 副本 (3)"]
   })

执行主函数的方法

   /**
    * @description 查找函数
    * @param {String} path 路径
    * @param {String} target 目标路径
    * @param {Object} opts 配置
    * {
    *   filter { String | Array } 过滤条件 
    *   => 过滤的文件夹不会遍历下去 例如node_modules
    * }
    * @return {Array}
    */

   // 以下代码的意思是查找 D:\\我的项目2这个文件夹中所有的dist
   findModules("D:\\我的项目2", "dist", {
    filter: ["node_modules"],
    // externals: ["test1 - 副本 (2)", "test1 - 副本 (3)"]
   })

执行查找函数的截图

   /**
    * @description 查找函数
    * @param {String} path 路径
    * @param {Array} externals 排除条件 
    * => 包含在其中文件夹不会被删除
    * @return {Void}
    */

   // 以下代码的意思是清除 
   // "D:\\testClear\\test1 "D:\\testClear\\test2" "D:\\testClear\\test3" 这三个文件夹 
   // 忽略文件夹名字中含有test2的文件夹
   clear(["D:\\testClear\\test1", "D:\\testClear\\test2", "D:\\testClear\\test3"], ["test2"])

执行清除函数的截图