fx43-node
Detecting changed files via caching file modification time.
Installation
# npm npm install --save fx43 # yarn yarn add fx43
Run tests:
# npm npm test # yarn yarn test
Usage
Fx43 offers 3 ways to track files:
- All files mode: all files are tracked.
- Ignore file mode: like
.gitignore
, tracks files in respect to nested ignore files. - Custom mode: tracks files filtered by custom JavaScript functions.
All files mode
;// ES5: const startAllFilesModeAsync = require('fx43').startAllFilesModeAsync; : Promise<string>;
Ignore file mode
;// ES5: const startIgnoreFileModeAsync = require('fx43').startIgnoreFileModeAsync; : Promise<string>;
Custom mode
;// ES5: const startCustomModeAsync = require('fx43').startCustomModeAsync; : Promise<string>;
Example
Suppose you have some files in a directory named data
:
- data/
index.html
main.js
style.css
lib/
lib.js
You need to track all changed .js
files. In this case, you can use ignore file mode. Define an ignore file like .gitignore
, for example, .myignore
with the following contents:
# .myignore
# put this file to the root folder of the project
# ignore html and css files
*.html
*.css
Then call fx43 APIs like this:
; { const files = await ; console;} async { await ;};
# run the program node example.js# output 2 file changed.main.jslib/lib.js # run the program node example.js# output 0 file changed. # modify and create some files touch ./data/lib/lib.jstouch ./data/new.js# run the program node example.js# output 2 file changed.lib/lib.jsnew.js # modify an irrelevant file touch ./data/style.css# run the program node example.js# output 0 file changed.
For more examples, see examples.