globcat
TypeScript icon, indicating that this package has built-in type declarations

3.1.1 • Public • Published

globcat

npm module downloads npm version node version npm license GitHub issues prettier.io

Concatenate files in alphabetical order from command line with glob pattern.

Install

npm install [--global] globcat

Usage

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. For option details please view the glob package. Thanks glob and minimatch for your excellence! :)

Command Line

Using CLI arguments:

globcat path/*.txt other/**/*.txt --output combined.txt

Using pipes:

cat file-with-paths.txt | globcat > combined.txt

Oneliner without installing using npx, use --quiet to suppress output from npx itself:

npx --quiet globcat *.txt > all.txt

To see available options run globcat --help.

Package Sidebar

Install

npm i globcat

Weekly Downloads

360

Version

3.1.1

License

MIT

Unpacked Size

15 kB

Total Files

9

Last publish

Collaborators

  • smonn