mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
fs.isFile(path) returns false if given path does not exist
This commit is contained in:
@@ -127,6 +127,15 @@ bool NativeHandler::Execute(const CefString& name,
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (name == "isFile") {
|
||||
NSString *path = stringFromCefV8Value(arguments[0]);
|
||||
|
||||
BOOL isDir = false;
|
||||
BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDir];
|
||||
retval = CefV8Value::CreateBool(exists && !isDir);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (name == "remove") {
|
||||
NSString *path = stringFromCefV8Value(arguments[0]);
|
||||
|
||||
|
||||
@@ -1,6 +1,20 @@
|
||||
fs = require 'fs'
|
||||
|
||||
describe "fs", ->
|
||||
describe ".isFile(path)", ->
|
||||
fixturesDir = require.resolve('fixtures')
|
||||
beforeEach ->
|
||||
|
||||
it "returns true with a file path", ->
|
||||
expect(fs.isFile(fs.join(fixturesDir, 'sample.js'))).toBe true
|
||||
|
||||
it "returns false with a directory path", ->
|
||||
expect(fs.isFile(fixturesDir)).toBe false
|
||||
|
||||
it "returns false with a non-existent path", ->
|
||||
expect(fs.isFile(fs.join(fixturesDir, 'non-existent'))).toBe false
|
||||
expect(fs.isFile(null)).toBe false
|
||||
|
||||
describe ".directory(path)", ->
|
||||
describe "when called with a file path", ->
|
||||
it "returns the path to the directory", ->
|
||||
|
||||
@@ -51,7 +51,7 @@ module.exports =
|
||||
# Returns true if the file specified by path exists and is a
|
||||
# regular file.
|
||||
isFile: (path) ->
|
||||
not $native.isDirectory path
|
||||
$native.isFile path
|
||||
|
||||
# Returns an array with all the names of files contained
|
||||
# in the directory path.
|
||||
|
||||
Reference in New Issue
Block a user