마지막으로 파일/폴더의 변경 사항을 감시할 수 있는 watch 메서드를 알아보겠습니다. 빈 텍스트 파일인 target.txt를 만들고 watch.js를 작성합니다.
watch.js
const fs = require('fs');
fs.watch('./target.txt', (eventType, filename) => {
console.log(eventType, filename);
});
마지막으로 파일/폴더의 변경 사항을 감시할 수 있는 watch 메서드를 알아보겠습니다. 빈 텍스트 파일인 target.txt를 만들고 watch.js를 작성합니다.
watch.js
const fs = require('fs');
fs.watch('./target.txt', (eventType, filename) => {
console.log(eventType, filename);
});