问题
I need to perform an action when files from a directory are created, renamed, or deleted. But not when content inside a file changes.
how can i do this with native node.js?
I tried
const fs = require('fs')
const path = require('path')
const ROOT_PATH = path.resolve('components')
fs.watch(ROOT_PATH, (eventType, filename) => {
console.log(eventType)
})
according to the documentation, eventType should return rename for creating, renaming, deleting.
And change when the content changes.
but the problem is that sometimes when I change the contents of some file inside the components directory, eventType returnsrename when should it be change....
so I am not able to differentiate creation, rename, delete fromcontent change
can someone help me with a native node solution with the fs module?
来源:https://stackoverflow.com/questions/56926903/differentiate-creation-renaming-and-updating-content-of-files-with-node