Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Adding a file to a watched directory fires the 'update' instead of the 'add' event #4

@andrecasal

Description

@andrecasal

Running the following code and adding a file to '/' writes "Config file updated!" to the console.

Running on node v9.4.0.

saw('/', {dot : true}).on('ready', (files) => {
	console.log("Ready! ");
}).on('add', (file) => {
	if(file.stat.isFile()) {
		if(file.name == this.configFilename) {
			console.log("Config file added!");
		}
	}
}).on('remove', (file) => {
	if(file.stat.isFile()) {
		if(file.name == this.configFilename) {
			console.log("Config file removed!");
		}
	}
}).on('update', (file) => {
	if(file.stat.isFile()) {
		if(file.name == this.configFilename) {
			console.log("Config file updated!");
		}
	}
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions