Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/smonn/globcat
Concatenate files from command line with glob pattern.
https://github.com/smonn/globcat
Last synced: 22 days ago
JSON representation
Concatenate files from command line with glob pattern.
- Host: GitHub
- URL: https://github.com/smonn/globcat
- Owner: smonn
- License: mit
- Created: 2015-08-25T14:27:16.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2024-03-11T07:30:21.000Z (11 months ago)
- Last Synced: 2024-11-28T22:52:09.579Z (about 2 months ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/globcat
- Size: 1.09 MB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# globcat
[![npm module downloads](http://img.shields.io/npm/dt/globcat.svg)](https://www.npmjs.org/package/globcat)
[![npm version](https://img.shields.io/npm/v/globcat.svg)](https://www.npmjs.org/package/globcat)
[![node version](https://img.shields.io/node/v/globcat.svg)](https://www.npmjs.org/package/globcat)
[![npm license](https://img.shields.io/npm/l/globcat.svg)](https://raw.githubusercontent.com/smonn/globcat/master/LICENSE)
[![GitHub issues](https://img.shields.io/github/issues/smonn/globcat.svg)](https://github.com/smonn/globcat/issues)
[![prettier.io](https://img.shields.io/badge/code%20style-prettier.io-brightgreen.svg)](https://prettier.io)Concatenate files in alphabetical order from command line with glob pattern.
## Install
```sh
npm install [--global] globcat
```## Usage
```javascript
import globcat from 'globcat'
const options = {
/*...*/
}// just the one...
globcat('**/*.txt', (err, contents) => {
// contents contains the file contents of the matched files
// err is an error object or null
})// ... or with array
globcat(['path/to/file.txt', 'other/path/*.txt'], options, (err, contents) => {
// contents contains the file contents of the matched files
// err is an error object or null
})// as promise
globcat(['path/to/file.txt', 'other/path/*.txt'], options)
.then(function (contents) {
// use contents
})
.catch(function (err) {
// handle error
})
```### Options
- `stream` Set to `true` to get a readable stream instead of string in the
callback. Defaults to `false`.
- `glob` Is passed through to [glob][glob]. For option details please
view the glob package. Thanks glob and minimatch for your excellence! :)[glob]: https://www.npmjs.com/package/glob
## Command Line
Using CLI arguments:
```sh
globcat path/*.txt other/**/*.txt --output combined.txt
```Using pipes:
```sh
cat file-with-paths.txt | globcat > combined.txt
```Oneliner without installing using `npx`, use `--quiet` to suppress output from
`npx` itself:```sh
npx --quiet globcat *.txt > all.txt
```To see available options run `globcat --help`.