Introduce atom.directory-provider service.

A `Project` will always have a `DefaultDirectoryProvider` that
will be used if there are no other `DirectoryProvider` objects
that can produce a `Directory` for a path.
This commit is contained in:
Michael Bolin
2015-02-12 15:47:09 -08:00
parent c728ad6d57
commit 461cd8c5fe

View File

@@ -11,6 +11,25 @@ describe "DefaultDirectoryProvider", ->
directory = provider.directoryForURISync(tmp)
expect(directory.getPath()).toEqual tmp
it "normalizes its input before creating a Directory for it", ->
provider = new DefaultDirectoryProvider()
tmp = temp.mkdirSync()
nonNormalizedPath = tmp + path.sep + ".." + path.sep + path.basename(tmp)
expect(tmp.contains("..")).toBe false
expect(nonNormalizedPath.contains("..")).toBe true
directory = provider.directoryForURISync(nonNormalizedPath)
expect(directory.getPath()).toEqual tmp
it "creates a Directory for its parent dir when passed a file", ->
provider = new DefaultDirectoryProvider()
tmp = temp.mkdirSync()
file = path.join(tmp, 'example.txt')
fs.writeFileSync(file, 'data')
directory = provider.directoryForURISync(file)
expect(directory.getPath()).toEqual tmp
describe ".directoryForURI(uri)", ->
it "returns a Promise that resolves to a Directory with a path that matches the uri", ->
provider = new DefaultDirectoryProvider()