0.2.2 • Published 3 years ago

block-finder v0.2.2

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

Block Finder

Block Finder combines glob-based file scans with regex-based token matches to find, parse, and extract multiline heredoc patterns from text files … and it does it really fast.

Usage

[~] npm i block-finder
// modules
const bf = require('block-finder');

// configure options
const options = {
  cwd: '.',
  glob: '**/*.(js|md)',
  ignore: '**/node_modules',
  start: '/** START **/',
  stop: '/** STOP **/',
};

// promise
bf(options).then(console.log).catch(console.error);

// callback
bf(options, (err, results) => (!!err) ? console.error(err) : console.log(results));

// sync
try {
  console.log(bf({ ...options, mode: 'sync' }));
} catch (err) {
  console.error(err);
}

Options

keytypedefaultdescription
cwdStringprocess.cwd()Current working directory to start searches from
globString|ArraynoneGlob patterns to be used for file searches
ignoreString|Array**/node_modulesGlob patterns to ignore in file searches
modeStringasyncWhether to run in sync or async mode (default=async)
startString|RegExpnoneStarting text block search string pattern
stopString|RegExpnoneStopping text block search string pattern

License

MIT License