Event when new directory is added to the project?


#1

Hi,
there is a new feature where atom has a consept of multiple folders opened for one project.
They even deprecated atom.project.getPath() in favour of atom.project.getPaths()

I need to watch all the open directories in a package I maintain. So I need some kind of event to subscribe to which would fire whenever user does File>Open or File>Add project folder

Is there anything in place now in latest 0.190?


#2

You can use atom.project.onDidChangePaths.

atom.project.onDidChangePaths (paths) ->
  # paths is an array of all project paths

This will fire whenever a path is added or removed. You’ll have to do your own processing to figure out which path was just added - probably store the paths whenever they change and find which paths are new.