Skip to content

Commit

Permalink
Add cfg.ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
chleck committed Feb 7, 2013
1 parent 795403c commit 4066dd3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions bin/i18n
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function init() {
if(typeof scheme[base] !== 'undefined') {
cfg.n = scheme[base][1];
cfg.rule = scheme[base][2] || '(n == 1 ? 0 : 1)';
cfg.ignore = [ 'i18n', 'node_modules' ];
targets();
} else {
console.log('No language rules for "%s".', base);
Expand Down Expand Up @@ -205,6 +206,12 @@ function collect() {

// Directory traversal
function grep(dir) {
function ignore(file) {
for(var i in cfg.ignore) {
if(file.match(cfg.ignore[i])) return true;
}
return false;
}
// Get dir content
try {
var files = fs.readdirSync(dir);
Expand All @@ -215,6 +222,7 @@ function collect() {

for(var i in files) {
var file = path.join(dir, files[i]);
if(ignore(file)) continue;
try {
var s = fs.statSync(file);
} catch(e) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Dmitry Chleck <dmitrychleck@gmail.com>",
"license": "MIT",
"name": "locale-tools",
"version": "0.0.1",
"version": "0.0.2",
"description": "Tools for locale-js",
"keywords": "locale-js locale i18n tools",
"main": "index.js",
Expand Down
Empty file added test/i18n/ignored.js
Empty file.
4 changes: 4 additions & 0 deletions test/i18n/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"base": "en",
"n": 2,
"rule": "(n == 1 ? 0 : 1)",
"ignore": [
"i18n",
"node_modules"
],
"targets": {
"ru": {
"n": 3,
Expand Down

0 comments on commit 4066dd3

Please sign in to comment.