sx-grab-files
Version:
文件抓取
41 lines (31 loc) • 1.07 kB
Markdown
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
```
$ yarn