I’m trying to write a plugin that finds project files for a opened source file (cargo file for a rust file). My idea was to check the directory, and to go up one level if no project file was found. This would be done until the file system root is found. However with the following code Atom gets stuck in an endless loop.
I’m thankful for every critique and hint.
findProjectDir: (path) -> parent = fs.normalize (parent + '/..') # stop recursion at file system root if path == parent false cargoFile = fs.listSync(parent, ['toml']) console.log cargoFile if cargoFile.length > 0 console.log 'Found cargo file' cargoFile else console.log 'Nothing found, recourse' @test parent search: -> console.log 'Searching...' path = atom.workspace.getActiveTextEditor().getPath() @findProjectDir path