UNPKG

1.89 kBMarkdownView Raw
1# globcat
2
3Concatenate files from command line with glob pattern.
4
5# Install
6
7```sh
8npm install [-g] globcat
9```
10
11# Usage
12
13```javascript
14var globcat = require("globcat");
15
16// just the one...
17globcat("**/*.txt", options, function (err, contents) {
18 // contents contains the file contents of the matched files
19 // err is an error object or null
20});
21
22// ... or with array
23globcat(["path/to/file.txt", "other/path/*.txt"], options, function (err, contents) {
24 // contents contains the file contents of the matched files
25 // err is an error object or null
26});
27
28// as promise
29globcat(["path/to/file.txt", "other/path/*.txt"], options)
30 .then(function(contents) {
31 // use contents
32 })
33 .catch(function(err) {
34 // handle error
35 });
36```
37
38## Options
39
40- `stream` Set to `true` to get a readable stream instead of string in the
41 callback. Defaults to `false`.
42- `glob` Is passed through to [glob][glob]. For option details please
43 view the glob package. Thanks glob and minimatch for your excellence! :)
44
45[glob]: https://www.npmjs.com/package/glob
46
47## Command Line
48
49Using CLI arguments:
50
51```sh
52globcat path/*.txt other/**/*.txt --output combined.txt
53```
54
55Using pipes:
56
57```sh
58cat file-with-paths.txt | globcat > combined.txt
59```
60
61# Changelog
62
63## 0.4.0
64
65- Updated package dependencies.
66- Switched from JSHint to ESLint.
67- Introduced promise support.
68
69## 0.3.1
70
71- Minor refactoring of command line code.
72- Updated async dependency.
73
74## 0.3.0
75
76- Switched to ES6 code style.
77- Updated package dependencies.
78
79## 0.2.3
80
81- Added error handling when trying to stream directory.
82
83## 0.2.2
84
85- Applied JSCS and JSHint through Gulp.
86
87## 0.2.1
88
89- Removed dependency on shelljs for string results.
90
91## 0.2.0
92
93- Added support to return readable streams instead of string.
94- CLI now uses streams to write output.
95- Fixed missing feature to forward glob options.
96
97## 0.1.6
98
99- Updated package dependencies.