Coder Social home page Coder Social logo

path-exists-cli's Introduction

path-exists-cli

Check if a path exists, cross-platform.

Install

$ npm install --global path-exists-cli

Usage

$ path-exists --help

  Usage
    $ path-exists <path>

  Example
    $ path-exists foo && echo "exists" || echo "doesn't exist"

Related

path-exists-cli's People

Contributors

mk-pmb avatar richienb avatar sindresorhus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

path-exists-cli's Issues

Ahm... Do you know about `test`?

Sorry if this isn't relevant. This repository showed up on my GitHub newsletter.

Do you know the shell's if statement is actually just syntactic sugar for the test coreutils utility?

http://www.gnu.org/software/coreutils/manual/html_node/test-invocation.html#test-invocation

So on pretty much any shell, you can run:

$ test -e asdf && echo "asdf exists"
$ test -d adsf && echo "adsf exists and is a directory"

And more... You can test for a file's length, it's permissions, it's type, if it's executable, if it's a socket, if it's newer than another file... You can make assertions over strings etc.

This specific case of test can be rewritten as:

$ if [ -e asdf ]; then echo "asdf exists"; fi
$ if [ -d adsf ]; then echo "asdf exists and is a directory"; fi

This is also how loops work in the shell, as far as I recall. Heh... A loop that spawns a Node.js runtime on every iteration would be pretty bad.


I just think it's a little weird for this kind of stuff to exist and even require another module to work...

This would be a pretty good example of going to far with modules, don't you think?

test from coreutils is an example of a useful, fast implementation of something that does 1 thing in the UNIX way... Which sort of means constructing a verb that's modular enough to be composed, but useful enough... A verb.

It seems like if this utility's approach was going to write coreutils, instead of test, there'd be:

  • path-exists
  • path-exists-and-is-directory
  • path-exists-and-is-directory-and-is-newer-than
  • path-exists-and-has-filename-equal-to

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.