Merge pull request #5795 from mostafaeweda/master

Default directory provider should handle only local filesystem directories
This commit is contained in:
Max Brunsfeld
2015-03-02 16:04:54 -08:00
2 changed files with 17 additions and 3 deletions

View File

@@ -78,6 +78,20 @@ describe "Project", ->
expect(directories.length).toBe 1
expect(directories[0].getPath()).toBe tmp
it "gets the parent directory from the default directory provider if it's a local directory", ->
tmp = temp.mkdirSync()
atom.project.setPaths([path.join(tmp, "not-existing")])
directories = atom.project.getDirectories()
expect(directories.length).toBe 1
expect(directories[0].getPath()).toBe tmp
it "only normalizes the directory path if it isn't on the local filesystem", ->
nonLocalFsDirectory = "custom_proto://abc/def"
atom.project.setPaths([nonLocalFsDirectory])
directories = atom.project.getDirectories()
expect(directories.length).toBe 1
expect(directories[0].getPath()).toBe path.normalize(nonLocalFsDirectory)
it "tries to update repositories when a new RepositoryProvider is registered", ->
tmp = temp.mkdirSync('atom-project')
atom.project.setPaths([tmp])

View File

@@ -16,10 +16,10 @@ class DefaultDirectoryProvider
directoryForURISync: (uri) ->
projectPath = path.normalize(uri)
directoryPath = if fs.isDirectorySync(projectPath)
projectPath
else
directoryPath = if !fs.isDirectorySync(projectPath) and fs.isDirectorySync(path.dirname(projectPath))
path.dirname(projectPath)
else
projectPath
new Directory(directoryPath)