Pankaj Patel
Pankaj Patel

Pankaj Patel

Today's npm package: is-glob

Pankaj Patel's photo
Pankaj Patel
ยทJun 9, 2021ยท

1 min read

Subscribe to my newsletter and never miss my upcoming articles

Play this article

Today's npm package is is-glob

While creating Node.js based CLIs which is working with Files and Directories; you might wanna work with Glob .

And when working with Glob, you need to know when the passed argument is a glob or not.

The package is-glob will help you in this case and it will return true only when the passed string is a Glob

const fs = require('fs');
const path = require('path');
const isGlob = require('is-glob');
const file = process.argv.slice(2);

if (isGlob(file)) {
  // process the Glob

// process the file
const fileData = fs.readFileSync(path.resolve(process.cwd(), file));

Stay tuned for tomorrow's package of the Day.

Share this