argv-auto-glob

1.0.1 • Public • Published

argv-auto-glob.js npm AppVeyor Status Travis CI Status

automatically expand globs (cross-platform) for the process.argv array (or similar)

What is this?

Popular shells on macOS and Linux automatically expand globs prior to executing commands. However, the default shells on Windows do not.

This library checks a process.argv-like array of strings, detects any globs, and expands the globs. This is very convenient for developing consistent cross-platform CLI tools.

Usage

argvAutoGlob (argv, globOptions)

Example

We execute a Node.js script like so:

  • node path/to/index.js **/*.txt

where our index.js file contains:

#! /usr/bin/env node
const argvAutoGlob = require('argv-auto-glob')
 
process.argv
// => (Windows) ['.../node', '.../index.js', '**/*.txt']
// => (bash/zsh) ['.../node', '.../index.js', 'example.txt', 'dir/more.txt', ... ]
 
process.argv = argvAutoGlob(process.argv)
 
process.argv
// => (all) ['.../node', '.../index.js', 'example.txt', 'dir/more.txt', ... ]

Readme

Keywords

Package Sidebar

Install

npm i argv-auto-glob

Weekly Downloads

0

Version

1.0.1

License

MIT

Last publish

Collaborators

  • jokeyrhyme