Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jokeyrhyme/argv-auto-glob.js
automatically expand globs (cross-platform) for the `process.argv` array (or similar)
https://github.com/jokeyrhyme/argv-auto-glob.js
Last synced: 21 days ago
JSON representation
automatically expand globs (cross-platform) for the `process.argv` array (or similar)
- Host: GitHub
- URL: https://github.com/jokeyrhyme/argv-auto-glob.js
- Owner: jokeyrhyme
- License: mit
- Created: 2016-08-18T01:02:35.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-06-02T23:53:23.000Z (over 4 years ago)
- Last Synced: 2024-04-25T12:21:27.606Z (7 months ago)
- Language: JavaScript
- Size: 167 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# argv-auto-glob.js [![npm](https://img.shields.io/npm/v/argv-auto-glob.svg?maxAge=2592000)](https://www.npmjs.com/package/argv-auto-glob) [![AppVeyor Status](https://img.shields.io/appveyor/ci/jokeyrhyme/argv-auto-glob-js/master.svg)](https://ci.appveyor.com/project/jokeyrhyme/argv-auto-glob-js) [![Travis CI Status](https://travis-ci.org/jokeyrhyme/argv-auto-glob.js.svg?branch=master)](https://travis-ci.org/jokeyrhyme/argv-auto-glob.js)
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)
- argv: Array
- globOptions: see https://www.npmjs.com/package/glob#options
- returns Array
#### Example
We execute a Node.js script like so:
- `node path/to/index.js **/*.txt`
where our index.js file contains:
```js
#! /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', ... ]
```