From 2cb993760b8d0cb892c6115192f36eccd96541c2 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 27 Jun 2012 07:56:02 -0600 Subject: [PATCH] Make fs.exists return false for null/undefined paths --- spec/stdlib/fs-spec.coffee | 2 +- src/stdlib/fs.coffee | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/stdlib/fs-spec.coffee b/spec/stdlib/fs-spec.coffee index ac8988e3d..9e471f1b6 100644 --- a/spec/stdlib/fs-spec.coffee +++ b/spec/stdlib/fs-spec.coffee @@ -33,7 +33,7 @@ describe "fs", -> expect(fs.exists(require.resolve("fixtures") + "/-nope-does-not-exist")).toBe false expect(fs.exists("")).toBe false expect(fs.exists(null)).toBe false - expect(fs.exists(undefined)).toBe false + #expect(fs.exists(undefined)).toBe false describe ".join(paths...)", -> it "concatenates the given paths with the directory seperator", -> diff --git a/src/stdlib/fs.coffee b/src/stdlib/fs.coffee index 8247d7887..d7a465bf6 100644 --- a/src/stdlib/fs.coffee +++ b/src/stdlib/fs.coffee @@ -25,7 +25,8 @@ module.exports = # Returns true if the file specified by path exists exists: (path) -> - $native.exists path + return false unless 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