pax_global_header00006660000000000000000000000064127113660610014515gustar00rootroot0000000000000052 comment=4696c60a8b2b9ac61902aa9eab7cb326ab6005c8 path-exists-3.0.0/000077500000000000000000000000001271136606100137665ustar00rootroot00000000000000path-exists-3.0.0/.editorconfig000066400000000000000000000002761271136606100164500ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [{package.json,*.yml}] indent_style = space indent_size = 2 path-exists-3.0.0/.gitattributes000066400000000000000000000000141271136606100166540ustar00rootroot00000000000000* text=auto path-exists-3.0.0/.gitignore000066400000000000000000000000151271136606100157520ustar00rootroot00000000000000node_modules path-exists-3.0.0/.travis.yml000066400000000000000000000000671271136606100161020ustar00rootroot00000000000000sudo: false language: node_js node_js: - '6' - '4' path-exists-3.0.0/index.js000066400000000000000000000003741271136606100154370ustar00rootroot00000000000000'use strict'; const fs = require('fs'); module.exports = fp => new Promise(resolve => { fs.access(fp, err => { resolve(!err); }); }); module.exports.sync = fp => { try { fs.accessSync(fp); return true; } catch (err) { return false; } }; path-exists-3.0.0/license000066400000000000000000000021371271136606100153360ustar00rootroot00000000000000The MIT License (MIT) 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-3.0.0/package.json000066400000000000000000000012011271136606100162460ustar00rootroot00000000000000{ "name": "path-exists", "version": "3.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": ">=4" }, "scripts": { "test": "xo && ava" }, "files": [ "index.js" ], "keywords": [ "path", "exists", "exist", "file", "filepath", "fs", "filesystem", "file-system", "access", "stat" ], "devDependencies": { "ava": "*", "xo": "*" }, "xo": { "esnext": true } } path-exists-3.0.0/readme.md000066400000000000000000000024301271136606100155440ustar00rootroot00000000000000# 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 Because [`fs.exists()`](https://nodejs.org/api/fs.html#fs_fs_exists_path_callback) is being [deprecated](https://github.com/iojs/io.js/issues/103), but 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 --save path-exists ``` ## Usage ```js // foo.js const pathExists = require('path-exists'); pathExists('foo.js').then(exists => { console.log(exists); //=> true }); ``` ## API ### pathExists(path) Returns a promise for a boolean 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-3.0.0/test.js000066400000000000000000000003231271136606100153010ustar00rootroot00000000000000import test from 'ava'; import m from './'; test('async', async t => { t.true(await m('test.js')); t.false(await m('fail')); }); test('sync', t => { t.true(m.sync('test.js')); t.false(m.sync('fail')); });