https://github.com/electron-utils/fsnap
filesystem snapshot
https://github.com/electron-utils/fsnap
filesystem snapshot watch
Last synced: 2 months ago
JSON representation
filesystem snapshot
- Host: GitHub
- URL: https://github.com/electron-utils/fsnap
- Owner: electron-utils
- License: mit
- Created: 2017-04-02T17:39:04.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-06T06:18:40.000Z (about 8 years ago)
- Last Synced: 2025-03-15T23:05:42.487Z (2 months ago)
- Topics: filesystem, snapshot, watch
- Language: JavaScript
- Size: 48.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fsnap
[](https://travis-ci.org/electron-utils/fsnap)
[](https://ci.appveyor.com/project/jwu/fsnap)
[](https://david-dm.org/electron-utils/fsnap)
[](https://david-dm.org/electron-utils/fsnap#info=devDependencies)Diff filesystem snapshot results. Useful for file watch system.
## Install
```bash
npm install --save fsnap
```## Usage
```javascript
const fsnap = require('fsnap');let s1 = fsnap.create(path);
let s2 = fsnap.create(path);
let result = fsnap.diff(s1, s2);// do something...
console.log(result.deletes);
console.log(result.changes);
console.log(result.creates);
```## API Reference
## Methods
### fsnap.create(patterns, [options])
- `patterns` string|Array - See supported `minimatch` [patterns](https://github.com/isaacs/minimatch#usage).
- `options` object - See the `node-glob` [options](https://github.com/isaacs/node-glob#options).create snapshot from the given patterns.
### fsnap.diff(s1, s2)
- `s1` object - snapshot 1
- `s2` object - snapshot 2Returns `object`
- `deletes` array - path list of deleted files and directories.
- `creates` array - path list of created files and directories.
- `chagnes` array - path list of changed files and directories.### fsnap.simplify(result)
- `result` object - the result of `fsnap.diff`
Simplify the diff result by remove files contains in the directory in the same result.
## License
MIT © 2017 Johnny Wu