mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Bare minimum fix to the default directory provider
This commit is contained in:
@@ -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])
|
||||
|
||||
@@ -16,15 +16,12 @@ 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)
|
||||
|
||||
if fs.isDirectorySync(projectPath)
|
||||
return new Directory(directoryPath)
|
||||
else
|
||||
return null
|
||||
projectPath
|
||||
|
||||
new Directory(directoryPath)
|
||||
|
||||
# Public: Create a Directory that corresponds to the specified URI.
|
||||
#
|
||||
|
||||
@@ -39,7 +39,6 @@ class Project extends Model
|
||||
@emitter = new Emitter
|
||||
@buffers ?= []
|
||||
@rootDirectories = []
|
||||
@packageRootDirectoryPaths = []
|
||||
@repositories = []
|
||||
|
||||
@directoryProviders = [new DefaultDirectoryProvider()]
|
||||
@@ -204,12 +203,10 @@ class Project extends Model
|
||||
for provider in @directoryProviders
|
||||
break if directory = provider.directoryForURISync?(projectPath)
|
||||
if directory is null
|
||||
# DefaultDirectoryProvider doesn't handle specific directory protocols
|
||||
# Atom Packages may use packageDirectoryPaths to add their own paths later.
|
||||
@packageRootDirectoryPaths.push(projectPath)
|
||||
return
|
||||
else
|
||||
@rootDirectories.push(directory)
|
||||
# This should never happen because DefaultDirectoryProvider should always
|
||||
# return a Directory.
|
||||
throw new Error(projectPath + ' could not be resolved to a directory')
|
||||
@rootDirectories.push(directory)
|
||||
|
||||
repo = null
|
||||
for provider in @repositoryProviders
|
||||
|
||||
Reference in New Issue
Block a user