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