Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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)`
Expand All @@ -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.

---

Expand Down