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