sx-grab-files

0.0.1 • Public • Published

文件抓取工具

安装

$ yarn add sx-grab-files

使用

const GrabFiles = require('sx-grab-files');
const path = require('path');

const grabFiles = new GrabFiles({
    paths: path.resolve(__dirname, './pages/**/*.model.js'),
    content: true,
});

grabFiles.watch(function (result, event) {
    console.log(event, result);
});

const result = grabFiles.getResult();
console.log('grabFiles', result);

构造参数

参数 说明 类型 默认值
paths 需要抓取的目录,一般是/path/to/pages/**/*.jsx string or [string] -
ignored 需要忽略的文件 string or [string] -
content 是否进行文件读取操作 boolean false

实例方法

方法 返回值 说明
grab(filePath) {path, content, fileName, baseName} 基于filePath获取文件相关信息
getResult() [{path, content, fileName, baseName}] 获取所有文件信息
watch(cb) undefined 监听文件改变,调用cb,并将 result, event, pathName参数,传递给cb

Readme

Keywords

none

Package Sidebar

Install

npm i sx-grab-files

Weekly Downloads

3

Version

0.0.1

License

MIT

Unpacked Size

42.5 kB

Total Files

5

Last publish

Collaborators

  • shubinwang