Coder Social home page Coder Social logo

glob's Introduction

_glob

A Versatile CLI Tool for Efficient File Globbing

Globbing made easy! _glob is a command-line interface (CLI) tool designed to swiftly search and manipulate files based on patterns. Whether you're hunting for specific files, directories, or both, _glob has got you covered with its extensive feature set and intuitive usage.

Usage

_glob [options] <pattern>

Options

  • -a, --absolute: Return absolute paths for entries
  • -b, --baseNameMatch: Match the base name of the path
  • -c, --caseSensitiveMatch: Perform a case-sensitive match
  • -C, --concurrency <number>: Set the maximum number of concurrent requests
  • -f, --followSymbolicLinks: Follow symbolic links
  • -i, --ignore <pattern>: Add a pattern to exclude
  • -m, --markDirectories: Append / to directories
  • -o, --objectMode: Return objects instead of strings
  • -D, --onlyDirectories: Return only directories
  • -F, --onlyFiles: Return only files
  • -B, --uniqueBaseName: Return only unique filenames even if they are in different directories
  • -S, --stats: Return stats for entries
  • -s, --suppressErrors: Suppress errors
  • -t, --throwErrorOnBrokenSymbolicLink: Throw an error on broken symbolic links
  • -u, --unique: Ensure that the returned entries are unique
  • --cwd <path>: The current working directory for the glob
  • --dot: Include entries that begin with a .
  • -O --outputCollection <outputCollection>: Output the collection to a file
  • -h, --help: Display help for command

Example Usage as Library

// Use with relative paths
const stream = _glob('../!(node_modules)**/!(*.d)*.ts', { outputCollection: "./files.json" });

// Use with Windows drives or Linux
// The following example will search for all .ts files in the C:/Users directory, excluding the node_modules directory and excluding .d.ts files
const stream = _glob('C:/Users/!(node_modules)**/!(*.d)*.ts', { outputCollection: "./files.json" });

stream.pipe(process.stdout);

stream.on('data', (chunk) => {
    console.log(chunk.toString());
});

// This will be triggered when the stream is done and collect equals to true or outputCollection is set
stream.on('files', (files) => {
    console.log(files);
});

PowerShell Autocomplete

For easy usage with PowerShell autocomplete, _glob normalizes Windows paths. Here's an example:

# Use with PowerShell
_glob D:\agebrock\**\* 

Example Usage in PowerShell

# Glob all JSON files and read their contents
_glob '**/*.json' | ForEach-Object { Get-Content $_ }

Installation

Install _glob globally to access it from anywhere:

npm install -g @agebrock/glob

Contribution

Contributions are welcome! Feel free to open issues or pull requests on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Get globbing with _glob and experience the power of effortless file searching and manipulation. Happy coding! ๐Ÿš€

Available Scripts

  • clean - remove coverage data, Jest cache and transpiled files,
  • prebuild - lint source files and tests before building,
  • build - transpile TypeScript to ES6,
  • build:watch - interactive watch mode to automatically transpile source files,
  • lint - lint source files and tests,
  • prettier - reformat files,
  • test - run tests,
  • test:watch - interactive watch mode to automatically re-run tests

glob's People

Contributors

agebrock avatar

Watchers

 avatar

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.