search-act-replace
Advanced tools
Comparing version 0.0.1 to 0.0.2
26
index.js
@@ -0,9 +1,29 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var findit = require('findit'); | ||
var fs = require('fs'); | ||
var ignore = require('ignore'); | ||
function sar(path, regex, cb) { | ||
var finder = findit(path); | ||
function sar(root, regex, cb) { | ||
var finder = findit(root); | ||
var accepts = ignore() | ||
.addIgnoreFile(path.join(__dirname, '.sarignore')) | ||
.addIgnoreFile(path.join(root, '.sarignore')) | ||
.addIgnoreFile(path.join(root, '.gitignore')) | ||
.createFilter() | ||
; | ||
finder.on('directory', function (dir, stat, stop) { | ||
if (!accepts(dir)) { | ||
console.log('ignored folder' + dir); | ||
stop(); | ||
} | ||
}) | ||
finder.on('file', function (file, stat) { | ||
if (!accepts(file)) { | ||
console.log('ignored file'); | ||
return; | ||
} | ||
fs.readFile(file, 'utf-8', function (err, text) { | ||
@@ -10,0 +30,0 @@ |
{ | ||
"name": "search-act-replace", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Search through file system and replace after callback.", | ||
@@ -17,3 +17,6 @@ "main": "index.js", | ||
"findit": "~1.2.0" | ||
}, | ||
"dependencies": { | ||
"ignore": "~2.2.12" | ||
} | ||
} |
@@ -27,1 +27,6 @@ # Search-Act-Replace | ||
``` | ||
The script will automatically ignore `.git`, `.svn`, `node_modules`, | ||
and `bower_components` folders (have a look at the `.sarignore` file) as well | ||
as files specified in the roots `.gitignore` file as well as a custom | ||
`.sarignore` file in the root folder. |
3908
8
77
32
1
+ Addedignore@~2.2.12
+ Addedignore@2.2.19(transitive)