UNPKG

2.44 kBMarkdownView Raw
1[![Travis](https://img.shields.io/travis/smonn/globcat.svg)](https://travis-ci.org/smonn/globcat)
2[![Dependency Status](https://david-dm.org/smonn/globcat.svg)](https://david-dm.org/smonn/globcat)
3[![Coverage Status](https://coveralls.io/repos/github/smonn/globcat/badge.svg?branch=master)](https://coveralls.io/github/smonn/globcat?branch=master)
4[![npm module downloads](http://img.shields.io/npm/dt/globcat.svg)](https://www.npmjs.org/package/globcat)
5[![npm version](https://img.shields.io/npm/v/globcat.svg)](https://www.npmjs.org/package/globcat)
6[![node version](https://img.shields.io/node/v/globcat.svg)](https://www.npmjs.org/package/globcat)
7[![npm license](https://img.shields.io/npm/l/globcat.svg)](https://raw.githubusercontent.com/smonn/globcat/master/LICENSE)
8[![GitHub issues](https://img.shields.io/github/issues/smonn/globcat.svg)](https://github.com/smonn/globcat/issues)
9[![prettier.io](https://img.shields.io/badge/code%20style-prettier.io-brightgreen.svg)](https://prettier.io)
10
11# globcat
12
13Concatenate files from command line with glob pattern.
14
15## Install
16
17```sh
18npm install [--global] globcat
19```
20
21## Usage
22
23```javascript
24const globcat = require('globcat')
25const options = { /*...*/ }
26
27// just the one...
28globcat('**/*.txt', (err, contents) => {
29 // contents contains the file contents of the matched files
30 // err is an error object or null
31})
32
33// ... or with array
34globcat(['path/to/file.txt', 'other/path/*.txt'], options, (err, contents) => {
35 // contents contains the file contents of the matched files
36 // err is an error object or null
37})
38
39// as promise
40globcat(['path/to/file.txt', 'other/path/*.txt'], options)
41 .then(function(contents) {
42 // use contents
43 })
44 .catch(function(err) {
45 // handle error
46 })
47```
48
49### Options
50
51- `stream` Set to `true` to get a readable stream instead of string in the
52 callback. Defaults to `false`.
53- `glob` Is passed through to [glob][glob]. For option details please
54 view the glob package. Thanks glob and minimatch for your excellence! :)
55
56[glob]: https://www.npmjs.com/package/glob
57
58## Command Line
59
60Using CLI arguments:
61
62```sh
63globcat path/*.txt other/**/*.txt --output combined.txt
64```
65
66Using pipes:
67
68```sh
69cat file-with-paths.txt | globcat > combined.txt
70```
71
72Oneliner without installing using `npx`, use `--quiet` to suppress output from
73`npx` itself:
74
75```sh
76npx --quiet globcat *.txt > all.txt
77```
78
79To see available options run `globcat --help`.