diff --git a/README.md b/README.md index 4847b7e..c237dcf 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ npm install --save-dev broccoli-string-replace Replace `VERSION_STRING` with `1.6.5` in `app/main.js`: +Search for files by string pattern ```javascript var replace = require('broccoli-string-replace'); @@ -31,6 +32,45 @@ var tree = replace('app', { }); ``` +Search for files using a glob pattern +```javascript +var replace = require('broccoli-string-replace'); + +var tree = replace('app', { + files: [ '*.js' ], + pattern: { + match: /VERSION_STRING/g, + replacement: '1.6.5' + } +}); +``` + +Search for files using a regular expression +```javascript +var replace = require('broccoli-string-replace'); + +var tree = replace('app', { + files: [ new RegExp('main' + '(.*js)') ], + pattern: { + match: /VERSION_STRING/g, + replacement: '1.6.5' + } +}); +``` + +Search for files using a function +```javascript +var replace = require('broccoli-string-replace'); + +var tree = replace('app', { + files: [ function(x) { return x.indexOf('main') > -1; } ], + pattern: { + match: /VERSION_STRING/g, + replacement: '1.6.5' + } +}); +``` + ## Documentation ### `replace(inputTree, options)` @@ -39,7 +79,7 @@ var tree = replace('app', { `options.files` *{Array}* -The list of files to process the list of patterns against. This is an array of strings. +The list of files to process the list of patterns against. This is an array of strings, globs, regular expressions, or functions. ---