Package Exports
- is-there
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (is-there) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
is-there

Check if a file or directory exists in a given path.
Why? fs.exists
already does the job!
Because fs.exists
and fs.existsSync
will be are deprecated and in some cases we still need them!
fs.exists()
is an anachronism and exists only for historical reasons. There should almost never be a reason to use it in your own code. 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 tofs.exists()
andfs.open()
. Just open the file and handle the error when it's not there.fs.exists()
will be deprecated. (Source, emphasis added)
☁️ Installation
$ npm i --save is-there
📋 Example
// Dependencies
var IsThere = require("is-there");
// Paths to test
var paths = [
// exist
"dir"
, "dir/another"
, "dir/another/file"
, "dir/file"
, "file"
, "file.ext"
// don't exist
, "foo"
, "foo/bar"
, "foo.bar"
, "foo/bar.foo"
].map(function (c) {
return __dirname + "/contents/" + c;
});
// Sync
console.log("> Testing sync method.");
paths.forEach(function (c) {
console.log("> %s %s", c, IsThere(c) ? "exists" : "doesn't exist");
});
console.log("> Testing async method.");
function doSeq(i) {
i = i || 0;
var cPath = paths[i];
if (!cPath) { return; }
IsThere(cPath, function (exists) {
console.log("> %s %s", cPath, exists ? "exists" : "doesn't exist");
doSeq(i + 1);
});
}
doSeq();
📝 Documentation
IsThere(path, callback)
Checks if a file or directory exists on given path.
Params
- String
path
: The path to the file or directory. - Function
callback
: The callback function called with a boolean value representing if the file or directory exists. If this parameter is not a function, the function will run the synchronously and return the value.
Return
- IsThere|Boolean The
IsThere
function if thecallback
parameter was provided, otherwise a boolean value indicating if the file/directory exists or not.
😋 How to contribute
Have an idea? Found a bug? See how to contribute.
💫 Where is this library used?
If you are using this library in one of your projects, add it in this list. ✨
a-csv
(by jillix)—A lightweight CSV parser.artstack-downloader
—Download artworks from your following users.bible
—Read the Holy Bible via the command line.blah
—A command line tool to optimize the repetitive actions.bowerrc
(by Mithun Ayachit)—Switch between different .bowerrc filescdnjs-importer
—Easy way to import a library into CDNJS.cecil
(by Michael Burkman)—For running single-file NodeJS scripts with external dependenciesemartech-node-sass-json-importer
—Allows importing json in sass files parsed by node-sass.engine-app
(by jillix)—Engine app related helper functions.engine-composition-crud
(by jillix)—The default module for creating, reading, updating and deleting Engine instances.engine-tools
(by jillix)—Engine Tools library and CLI app.f-watcher
—Watch files for changes.find-file-in-dirs
—Find a file in different directories.firstant2gradle
(by Philip Rader)—Automatically converts an Ant build system to Gradle for FIRST Robotics Competition teamsfontify
(by Youssef Kababe)—Copy font files from node_modules folderfwatcher
—Watch files for changes.generator-arwen
(by Jason Villalon)—Generator Atomic Restify Web NodeJSgenerator-atomus
(by Jason Villalon)—Generator React Componentsgenerator-catena
(by Damir Kusar)—Yeoman generator for Meteor and AngularJSgenerator-catena-angular-meteor-bootstrap
(by Damir Kusar)—Yeoman generator for Meteor and AngularJSgenerator-catena-angular-meteor-material
(by Damir Kusar)—Yeoman generator for Meteor and AngularJSgenerator-leptir
(by Damir Kusar)—Yeoman generator for AngularJS with gulp, browserify, bootstrap, SCSS, angular-ui, angular-translate, karma, jasmine and ftp deploymentgenerator-leptir-angular-bootstrap
(by Damir Kusar)—Yeoman generator for AngularJS with gulp, browserify, bootstrap, SCSS, angular-ui, angular-translate, karma, jasmine and ftp deploymentgenerator-leptir-angular-material
(by Damir Kusar)—Yeoman generator for AngularJS with gulp, browserify, Angular-Material, SCSS, angular-ui, angular-translate, karma, jasmine and ftp deploymentgenerator-morf
(by p1100i)—A yeoman generator to bootstrap a finely tuned project [node, angular], w/ Grunt.gif-cli
—Gif animations in your terminal!git-issues
(by Gabriel Petrovay)—Git issues extension to list issues of a Git projectgit-stats
—Local git statistics including GitHub-like contributions calendars.git-stats-importer
—Imports your commits from a repository into git-stats history.gpm
—npm + git = gpm - Install NPM packages and dependencies from git repositories.grunt-md5symlink
(by peters)—Create symlink by the md5 of given files.gulp-app-build-tasks
(by Jimmy Fortin)—This module will add standard gulp tasks to start building a web application.gulp-common-build-tasks
(by Jimmy Fortin)—You can found in this library some utilities and tasks that can be shared between multiple gulp's build processes.hal-rc
—hints-and-lints rcheroku-docker
(by Hunter Loftis)—Use Docker to build and deploy Heroku appsidea
—A lightweight CLI tool and module for keeping ideas in a safe place quick and easy.image-to-ascii-cli
—View images in text format, in your terminal.jisc_build
(by Martin Wood-Mitrovski)—Shared jisc build scripts and configuration for JJA and JHTjoomlascan
—Searches paths for Joomla installations and outputs the installed version number.le-serf
(by Nathan McCallum)—Your trusty assistant in your Lacuna Expanse misadventures!low-cli
(by Jeremy Rylan)—undefinedmatanza
(by Alfredo Monteiro)—Matanza =======node-dynamo
(by Louis Larry)—Easily create and recreate dynamodb tables and sample data. This package provides the cli and sdk.node-sass-json-importer
—Allows importing json in sass files parsed by node-sass.npm-interlink
(by Orlin M Bozhinov)—becausenpm link ...
can be tediouspanes
(by Joel Chu)—PANES.JS core lib and cli http://panesjs.comparent-search
—Search files and folders in parent directories.payname
(by Florian CHEVALLIER)—Module nodejs permettant d'intégrer Payname à vos projetsramda-cli
(by Raine Virta)—A command-line tool for processing JSON with Ramda and LiveScriptreindex-cli
(by Reindex)—CLI interface for Reindexsingular_sake
(by Juan Castro Fernández)—Singular MVC PHP Framework command line toolsourcegate
(by Orlin M Bozhinov)—have any json object you wantsp-load
(by pavel06081991)—Modules loader. No lots of require calls on the top of files. On demand modules loading. Local modules.tithe
—Organize and track the tithe payments.typed-css-modules
(by quramy)—Creates .d.ts files from CSS Modules .css filesunity-asset-sync
(by Chris Jaynes)—Allows safe, effective sharing of code between Unity projects.unity-link
(by Chris Jaynes)—A utility for Unity developers to symlink scripts into their Assets folders. Useful for library development.uturi-caching
—undefinedvalkyrja
(by srcspider)—the deploy toolweb-term
—A full screen terminal in your browser.zow
(by Jeremy Rylan)—undefined