If passed a directory path, fs.directory returns the path it is given (not the parent dir)

This commit is contained in:
Nathan Sobo
2012-01-04 19:07:55 -07:00
parent 80e4fda2f9
commit 629c1ef239
2 changed files with 16 additions and 1 deletions

View File

@@ -25,7 +25,11 @@ module.exports =
# Return the dirname of the given path. That is the path with any trailing
# non-directory component removed.
directory: (path) ->
@absolute(path).replace(new RegExp(@base(path) + '$'), '')
absPath = @absolute(path)
if @isDirectory(absPath)
absPath.replace(/\/?$/, '/')
else
absPath.replace(new RegExp("/#{@base(path)}$"), '/')
# Returns true if the file specified by path exists
exists: (path) ->