From ef628f0ad48385932314e142789573bb4949bf06 Mon Sep 17 00:00:00 2001 From: Corey Johnson & Nathan Sobo Date: Thu, 29 Dec 2011 11:43:32 -0800 Subject: [PATCH] Add directory method to fs --- src/stdlib/fs.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/stdlib/fs.coffee b/src/stdlib/fs.coffee index 57fa14789..16ba66082 100644 --- a/src/stdlib/fs.coffee +++ b/src/stdlib/fs.coffee @@ -28,6 +28,11 @@ module.exports = changeWorkingDirectory: (path) -> OSX.NSFileManager.defaultManager.changeCurrentDirectoryPath path + # 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) + '$'), '') + # Returns true if the file specified by path exists exists: (path) -> OSX.NSFileManager.defaultManager.fileExistsAtPath_isDirectory path, null