Add fs.extension

This commit is contained in:
Corey Johnson
2012-05-01 14:07:05 -07:00
parent 7dbcb80339
commit cb0e576949
2 changed files with 19 additions and 0 deletions

View File

@@ -27,6 +27,17 @@ module.exports =
exists: (path) ->
$native.exists path
# Returns the extension of a file. The extension of a file is the
# last dot (excluding any number of initial dots) followed by one or
# more non-dot characters. Returns an empty string if no valid
# extension exists.
extension: (path) ->
match = @base(path).match(/\.[^\.]+$/)
if match
match[0]
else
""
join: (paths...) ->
return paths[0] if paths.length == 1
[first, rest...] = paths