JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 147908
  • Score
    100M100P100Q159029F
  • License MIT

Check if a file or directory exists in a given path.

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

is-there

Support me on Patreon Buy me a book PayPal Travis Version Downloads

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 to fs.exists() and fs.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

Checks if a file or directory exists on given path. Use without the new keyword.

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 synchronously and return the value.

Return

  • isThere|Boolean The isThere function if the callback parameter was provided, otherwise a boolean value indicating if the file/directory exists or not.

directory(path, callback)

Checks if the path exists and it is a directory.

Params

  • String path: The path to the directory.
  • Function callback: The callback function called with a boolean value representing if the directory exists. If this parameter is not a function, the function will run synchronously and return the value.

Return

  • isThere|Boolean The isThere function if the callback parameter was provided, otherwise a boolean value indicating if the directory exists or not.

file(path, callback)

Check if the path exists and it is a file.

Params

  • String path: The path to the file.
  • Function callback: The callback function called with a boolean value representing if the file exists. If this parameter is not a function, the function will run synchronously and return the value.

Return

  • isThere|Boolean The isThere function if the callback parameter was provided, otherwise a boolean value indicating if the file exists or not.

😋 How to contribute

Have an idea? Found a bug? See how to contribute.

💖 Support my projects

I open-source almost everything I can, and I try to reply everyone needing help using these projects. Obviously, this takes time. You can integrate and use these projects in your applications for free! You can even change the source code and redistribute (even resell it).

However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:

  • Starring and sharing the projects you like 🚀

  • PayPal—You can make one-time donations via PayPal. I'll probably buy a coffee tea. 🍵

  • Support me on Patreon—Set up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone).

  • Bitcoin—You can send me bitcoins at this address (or scanning the code below): 1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6

Thanks! ❤️

💫 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.
  • ajs—Asynchronous templating in Node.js
  • ali-oss-extra (by Jacky Tang)—Extend the official ali-oss with more convenient methods, such as listing, syncing or deleting a directory, put or delete a list of files etc.
  • artstack-downloader—Download artworks from your following users.
  • be-goods (by Orlin M Bozhinov)—let there be beverage goods
  • better-history (by Jiacai Liu)—💡 Get a better sense of browsing history via Chrome/Firefox
  • bible—Read the Holy Bible via the command line.
  • blah—A command line tool to optimize the repetitive actions.
  • bower-license-webpack-plugin (by S K)—Outputs licenses from 3rd party libraries to a file
  • bowerrc (by Mithun Ayachit)—Switch between different .bowerrc files
  • caipi (by Nathan Braun)—Caipi reactor - Isomorphic CMS based on ES6+React+webpack+mongo+etc
  • cdnjs-importer—Easy way to import a library into CDNJS.
  • cecil (by Michael Burkman)—For running single-file NodeJS scripts with external dependencies
  • confetti-cli (by Andrea Mangano)—Command line interface for Confetti, a tool for enriching your online slide decks.
  • emartech-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 teams
  • fontify (by Youssef Kababe)—Copy font files from node_modules folder
  • friendly-typed-css-modules (by themallen)—Creates .d.ts files from CSS Modules .css files
  • fwatcher—Watch files for changes.
  • gd-cli (by Sylvain Baronnet)—GD Command Line Interface
  • generator-arwen (by Jason Villalon)—Generator Atomic Restify Web NodeJS
  • generator-atomus (by Jason Villalon)—Generator React Components
  • generator-catena (by Damir Kusar)—Yeoman generator for Meteor and AngularJS
  • generator-catena-angular-meteor-bootstrap (by Damir Kusar)—Yeoman generator for Meteor and AngularJS
  • generator-catena-angular-meteor-material (by Damir Kusar)—Yeoman generator for Meteor and AngularJS
  • generator-leptir (by Damir Kusar)—Yeoman generator for AngularJS with gulp, browserify, bootstrap, SCSS, angular-ui, angular-translate, karma, jasmine and ftp deployment
  • generator-leptir-angular-bootstrap (by Damir Kusar)—Yeoman generator for AngularJS with gulp, browserify, bootstrap, SCSS, angular-ui, angular-translate, karma, jasmine and ftp deployment
  • generator-leptir-angular-material (by Damir Kusar)—Yeoman generator for AngularJS with gulp, browserify, Angular-Material, SCSS, angular-ui, angular-translate, karma, jasmine and ftp deployment
  • generator-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 project
  • git-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-rchints-and-lints rc
  • heroku-container-registry (by Hunter Loftis)—Use containers to build and deploy Heroku apps
  • heroku-container-tools (by Hunter Loftis)—Use containers to build and deploy Heroku apps
  • heroku-docker (by Hunter Loftis)—DEPRECATED: use heroku-container-tools
  • hg-plus (by Justin Dalrymple)—A Mercurial client for Node
  • idea—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.
  • is-git-check (by Dominik Winter)—Simple module to check whether a directory is a git repository or not
  • jisc_build (by Martin Wood-Mitrovski)—Shared jisc build scripts and configuration for JJA and JHT
  • joomlascan—Searches paths for Joomla installations and outputs the installed version number.
  • kaomojify (by kokororin)—Kaomojify Javascript code
  • kaomojify-webpack-plugin (by kokororin)—convert your built JavaScript code to Japanese kawaii kaomoji(かわいい顔文字)
  • kotori-webpack-plugin (by kokororin)—Yet another webpack plugin
  • le-serf (by Nathan McCallum)—Your trusty assistant in your Lacuna Expanse misadventures!
  • low-cli (by Jeremy Rylan)—undefined
  • matanza (by Alfredo Monteiro)—Matanza =======
  • memories (by data-doge)—cli for a timestamped markdown journal
  • minipod (by DonYang)—Customize cocoapods specs for just you need.
  • 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)—because npm link ... can be tedious
  • panes (by Joel Chu)—PANES.JS core lib and cli http://panesjs.com
  • parent-search—Search files and folders in parent directories.
  • payname (by Florian CHEVALLIER)—Module nodejs permettant d'intégrer Payname à vos projets
  • ramda-cli (by Raine Virta)—A command-line tool for processing JSON with Ramda and LiveScript
  • reindex-cli (by Reindex)—CLI interface for Reindex
  • singular_sake (by Juan Castro Fernández)—Singular MVC PHP Framework command line tool
  • sourcegate (by Orlin M Bozhinov)—have any json object you want
  • sp-load (by pavel06081991)—Modules loader. No lots of require calls on the top of files. On demand modules loading. Local modules.
  • tester-init—Init tests for tester.
  • tilda-init—Init cli applications.
  • tithe—Organize and track the tithe payments.
  • typed-css-modules (by quramy)—Creates .d.ts files from CSS Modules .css files
  • unity-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—undefined
  • valkctl—simple command wrapper
  • valkyrja (by srcspider)—the deploy tool
  • vimhelp (by thinca)—Show vim help.
  • viur-ignite-css (by VIUR)—Core of VIUR Ignite - a less framework
  • viur-ignite-html (by VIUR)—Simple Template Render | Extension of viur-ignite-css
  • viur-ignite-icons (by VIUR)—Icon libary | Extension of viur-ignite-css
  • viur-ignite-js (by VIUR)—Javascript Libary | Extension of viur-ignite-css
  • web-term—A full screen terminal in your browser.
  • wml (by dutzi)—Replaces npm link with something that actually works!
  • zow (by Jeremy Rylan)—undefined

📜 License

MIT © Ionică Bizău