mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
fs.directory returns empty string if path has no parent directory
This commit is contained in:
@@ -21,8 +21,9 @@ describe "fs", ->
|
||||
|
||||
describe "when called with a directory path", ->
|
||||
it "return the path it was given", ->
|
||||
expect(fs.directory(require.resolve('fixtures/dir'))).toBe require.resolve('fixtures')
|
||||
expect(fs.directory(require.resolve('fixtures/dir/'))).toBe require.resolve('fixtures')
|
||||
expect(fs.directory("/a/b/c")).toBe "/a/b"
|
||||
expect(fs.directory("/a")).toBe ""
|
||||
expect(fs.directory("a")).toBe ""
|
||||
|
||||
describe ".exists(path)", ->
|
||||
it "returns true when path exsits", ->
|
||||
|
||||
@@ -21,7 +21,9 @@ module.exports =
|
||||
# parent directory if the file is a directory. A terminal directory
|
||||
# separator is ignored.
|
||||
directory: (path) ->
|
||||
path.replace(new RegExp("/#{@base(path)}\/?$"), '')
|
||||
parentPath = path.replace(new RegExp("/#{@base(path)}\/?$"), '')
|
||||
return "" if path == parentPath
|
||||
parentPath
|
||||
|
||||
# Returns true if the file specified by path exists
|
||||
exists: (path) ->
|
||||
|
||||
Reference in New Issue
Block a user