pax_global_header00006660000000000000000000000064134512747220014521gustar00rootroot0000000000000052 comment=26b1adf80aa6761a7db35927a20cf59e0fd1a00d path-exists-4.0.0/000077500000000000000000000000001345127472200137735ustar00rootroot00000000000000path-exists-4.0.0/.editorconfig000066400000000000000000000002571345127472200164540ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 path-exists-4.0.0/.gitattributes000066400000000000000000000000231345127472200166610ustar00rootroot00000000000000* text=auto eol=lf path-exists-4.0.0/.gitignore000066400000000000000000000000271345127472200157620ustar00rootroot00000000000000node_modules yarn.lock path-exists-4.0.0/.npmrc000066400000000000000000000000231345127472200151060ustar00rootroot00000000000000package-lock=false path-exists-4.0.0/.travis.yml000066400000000000000000000000541345127472200161030ustar00rootroot00000000000000language: node_js node_js: - '10' - '8' path-exists-4.0.0/index.d.ts000066400000000000000000000006551345127472200157020ustar00rootroot00000000000000declare const pathExists: { /** Check if a path exists. @returns Whether the path exists. @example ``` // foo.ts import pathExists = require('path-exists'); (async () => { console.log(await pathExists('foo.ts')); //=> true })(); ``` */ (path: string): Promise; /** Synchronously check if a path exists. @returns Whether the path exists. */ sync(path: string): boolean; }; export = pathExists; path-exists-4.0.0/index.js000066400000000000000000000005331345127472200154410ustar00rootroot00000000000000'use strict'; const fs = require('fs'); const {promisify} = require('util'); const pAccess = promisify(fs.access); module.exports = async path => { try { await pAccess(path); return true; } catch (_) { return false; } }; module.exports.sync = path => { try { fs.accessSync(path); return true; } catch (_) { return false; } }; path-exists-4.0.0/index.test-d.ts000066400000000000000000000002471345127472200166540ustar00rootroot00000000000000import {expectType} from 'tsd'; import pathExists = require('.'); expectType>(pathExists('foo.ts')); expectType(pathExists.sync('foo.ts')); path-exists-4.0.0/license000066400000000000000000000021251345127472200153400ustar00rootroot00000000000000MIT License Copyright (c) Sindre Sorhus (sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. path-exists-4.0.0/package.json000066400000000000000000000011371345127472200162630ustar00rootroot00000000000000{ "name": "path-exists", "version": "4.0.0", "description": "Check if a path exists", "license": "MIT", "repository": "sindresorhus/path-exists", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=8" }, "scripts": { "test": "xo && ava && tsd" }, "files": [ "index.js", "index.d.ts" ], "keywords": [ "path", "exists", "exist", "file", "filepath", "fs", "filesystem", "file-system", "access", "stat" ], "devDependencies": { "ava": "^1.4.1", "tsd": "^0.7.2", "xo": "^0.24.0" } } path-exists-4.0.0/readme.md000066400000000000000000000026231345127472200155550ustar00rootroot00000000000000# path-exists [![Build Status](https://travis-ci.org/sindresorhus/path-exists.svg?branch=master)](https://travis-ci.org/sindresorhus/path-exists) > Check if a path exists NOTE: `fs.existsSync` has been un-deprecated in Node.js since 6.8.0. If you only need to check synchronously, this module is not needed. While [`fs.exists()`](https://nodejs.org/api/fs.html#fs_fs_exists_path_callback) is being [deprecated](https://github.com/iojs/io.js/issues/103), there's still a genuine use-case of being able to check if a path exists for other purposes than doing IO with it. Never use this before handling a file though: > In particular, checking if a file exists before opening it is an anti-pattern that leaves you vulnerable to race conditions: another process may remove the file between the calls to `fs.exists()` and `fs.open()`. Just open the file and handle the error when it's not there. ## Install ``` $ npm install path-exists ``` ## Usage ```js // foo.js const pathExists = require('path-exists'); (async () => { console.log(await pathExists('foo.js')); //=> true })(); ``` ## API ### pathExists(path) Returns a `Promise` of whether the path exists. ### pathExists.sync(path) Returns a `boolean` of whether the path exists. ## Related - [path-exists-cli](https://github.com/sindresorhus/path-exists-cli) - CLI for this module ## License MIT © [Sindre Sorhus](https://sindresorhus.com) path-exists-4.0.0/test.js000066400000000000000000000003771345127472200153170ustar00rootroot00000000000000import test from 'ava'; import pathExists from '.'; test('async', async t => { t.true(await pathExists('test.js')); t.false(await pathExists('fail')); }); test('sync', t => { t.true(pathExists.sync('test.js')); t.false(pathExists.sync('fail')); });