From 06bbd5283e4ffe22b1d81f005af9a13105f91f1a Mon Sep 17 00:00:00 2001 From: rene rubalcava Date: Fri, 10 Jul 2015 12:54:58 -0700 Subject: [PATCH 1/3] update examples in README with latest features --- README.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4847b7e..1f48eb8 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Replace `VERSION_STRING` with `1.6.5` in `app/main.js`: ```javascript var replace = require('broccoli-string-replace'); +// files with strings var tree = replace('app', { files: [ 'main.js' ], pattern: { @@ -29,6 +30,33 @@ var tree = replace('app', { replacement: '1.6.5' } }); + +// files with globs +var tree = replace('app', { + files: [ '*.js' ], + pattern: { + match: /VERSION_STRING/g, + replacement: '1.6.5' + } +}); + +// files with regular expressions +var tree = replace('app', { + files: [ new RegExp('main' + '(.*js)') ], + pattern: { + match: /VERSION_STRING/g, + replacement: '1.6.5' + } +}); + +// files with functions +var tree = replace('app', { + files: [ function(x) { return x.indexOf('main') > -1; } ], + pattern: { + match: /VERSION_STRING/g, + replacement: '1.6.5' + } +}); ``` ## Documentation @@ -39,7 +67,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. --- From f5a49d7b007767b608795654b21fca835210b9e2 Mon Sep 17 00:00:00 2001 From: Rene Rubalcava Date: Fri, 10 Jul 2015 13:00:55 -0700 Subject: [PATCH 2/3] Update examples --- README.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1f48eb8..d66e9eb 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,10 @@ 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'); -// files with strings var tree = replace('app', { files: [ 'main.js' ], pattern: { @@ -30,8 +30,12 @@ var tree = replace('app', { replacement: '1.6.5' } }); +``` + +Search for files using a glob pattern +```javascript +var replace = require('broccoli-string-replace'); -// files with globs var tree = replace('app', { files: [ '*.js' ], pattern: { @@ -39,8 +43,12 @@ var tree = replace('app', { replacement: '1.6.5' } }); +``` + +Search for files using a regular expression +```javascript +var replace = require('broccoli-string-replace'); -// files with regular expressions var tree = replace('app', { files: [ new RegExp('main' + '(.*js)') ], pattern: { @@ -48,7 +56,11 @@ var tree = replace('app', { replacement: '1.6.5' } }); +``` +Search for files using a function +```javascript +var replace = require('broccoli-string-replace'); // files with functions var tree = replace('app', { files: [ function(x) { return x.indexOf('main') > -1; } ], From 26ef08aac4cbdace4dc71546cb71c6d6b7dfae9d Mon Sep 17 00:00:00 2001 From: Rene Rubalcava Date: Fri, 10 Jul 2015 13:03:58 -0700 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d66e9eb..c237dcf 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ var tree = replace('app', { Search for files using a function ```javascript var replace = require('broccoli-string-replace'); -// files with functions + var tree = replace('app', { files: [ function(x) { return x.indexOf('main') > -1; } ], pattern: {