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

@geoscene/file-batch-script

v1.0.7

Published

* 支持多进程任务 * 通配符查找过滤文件。通配符的用法可以查阅[glob文档](https://www.npmjs.com/package/glob) * 可自定义处理文件 * 可输出基础操作日志 * 可扩展日志处理

Downloads

10

Readme

文件批处理脚本

  • 支持多进程任务
  • 通配符查找过滤文件。通配符的用法可以查阅glob文档
  • 可自定义处理文件
  • 可输出基础操作日志
  • 可扩展日志处理

版本依赖

node >= 14.18.0
npm >= 7

使用

# 安装依赖
$ npm install @geoscene/file-batch-script -g

# 初始化脚本
$ file-batch-script init
# 根据提示输入必要参数后,等待下载模板、依赖安装完毕

# 执行或自行修改配置
$ npm run default

# !!! 注意 !!!
# package.json 里配置的环境参数 default 需要和 default.config.js 对应。

模板文件说明

├── config                    # 脚本配置
│   └── default.config.js     # 初始脚本命令,可用于文本替换
├── keywordFiles              # 关键字文件存放,可自行调整
├── src                       # 代码存放地,可自行调整
├── .gitignore                
├── package.json

API

| 属性 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | after | 文件处理完毕后的回调 | () => void | - | | dealFn | 自定义文件处理函数。options配置在*.config.js中的自定义属性,子进程在调用dealFn时,会过滤掉 api 属性 | (filePath:string, options:object, callback:(msg: DealLog) => void) => void | required | | files | 要处理的文件列表,使用文件的绝对路径。优先级高于includes | string[] | - | | filterFiles | 自定义过滤文件 | (files: string[]) => string[] | - | | ignoreFiles | 忽略的文件,可使用通配符和字符串路径 | string[] | - | | includes | 通配符匹配目标文件,使用glob实现 | string[] | required | | logger | 日志配置,设置真值时启用日志记录。具体说明如下 | LoggerType | - | | multiProcess | 是否启用多进程处理,设为number可以控制进程数,true使用最大cpu数创建进程 | boolean number | true | | root | 目标文件根目录,配合includes使用。如不配置,会用上一级目录作为入口,并将过滤本目录 | string | - |

DealLog

| 类型 | 说明 | 备注 | | --- | --- | --- | | Log | 通用日志 | { type: string, message:string/number } | | string/number | 以字符串或数字传值,默认为log类型数据 | - | | array | 批量回传日志 | Log[] |

LoggerType

| 属性 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | types | 自定义日志处理类型和函数,函数返回false,本条日志会重新加入日志队列。type设为log/error,将覆盖内置的处理函数 | { [type:string]: (msg:string) => boolean } | - |