node-file-exists
Advanced tools
Comparing version 1.0.0 to 1.1.0
33
index.js
"use strict"; | ||
var fs_1 = require('fs'); | ||
function fileExists(pathToFile) { | ||
try { | ||
fs_1.accessSync(pathToFile, fs_1.F_OK); | ||
} catch (e) { | ||
if (e) { | ||
if (e.code !== 'ENOENT') { | ||
console.log(e); | ||
} | ||
return false; | ||
} | ||
} | ||
return true; | ||
function fileExists(path, silent) { | ||
if (silent === void 0) { silent = true; } | ||
try { | ||
fs_1.accessSync(path, fs_1.F_OK); | ||
} | ||
catch (e) { | ||
if (e) { | ||
if (!silent) { | ||
console.log(e); | ||
} | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = fileExists; | ||
exports.__esModule = true; | ||
exports["default"] = fileExists; |
{ | ||
"name": "node-file-exists", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Check if a file exists in Node.js. ES6 module compatible, non-depracated fs utils.", | ||
@@ -13,2 +13,7 @@ "main": "index.js", | ||
}, | ||
"files": [ | ||
"package.json", | ||
"README.md", | ||
"index.js" | ||
], | ||
"keywords": [ | ||
@@ -15,0 +20,0 @@ "file", |
@@ -18,4 +18,15 @@ # File Exists Sync | ||
exists('/path/to/file.js'); // true or false | ||
exists('/path/to/file.js'); | ||
// true or false | ||
``` | ||
##### Silent | ||
Pass in false as a second parameter to produce errors on failure. | ||
```js | ||
import exists from 'node-file-exists'; | ||
exists('/path/to/file.js', false); | ||
// true or Error | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1620
32