Skip to content
This repository has been archived by the owner on Dec 23, 2018. It is now read-only.

Commit

Permalink
honor .gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Condon committed Feb 17, 2012
1 parent 1a06f05 commit 601c24c
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 13 deletions.
Binary file added .DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions .cupboard
@@ -1,2 +1,7 @@
[commands]
proj = subl --project project.sublime-project


[ignore]
project.sublime-project
project.sublime-workspace
9 changes: 2 additions & 7 deletions .gitignore
@@ -1,9 +1,4 @@
node_modules
data
node_modules
beanpole node_modules
beanpole node_modules
beanpoll node_modules
beanpoll node_modules
.DS_Store

project.sublime-project
project.sublime-workspace
Binary file added conf/.DS_Store
Binary file not shown.
Binary file added lib/beans/.DS_Store
Binary file not shown.
47 changes: 43 additions & 4 deletions lib/beans/cbd.projects/getUpdatedFiles.js
@@ -1,7 +1,31 @@
var findit = require('findit'),
relativeDate = require('relative-date'),
exec = require('child_process').exec,
fs = require('fs');
fs = require('fs'),
_ = require('underscore'),
ini = require('ini');


function getIgnore(path, file) {
try {
return fs.readFileSync(path + "/" + file, "utf8").split(/\n+/g);
} catch(e) {
return [];
}
}

function getCbdIgnore(path) {

try {
var cfg = ini.parse(fs.readFileSync(path + "/.cupboard", "utf8"));

return cfg.ignore ? Object.keys(cfg.ignore) : [];
} catch(e) {
return [];
}

return [];
}

module.exports = function(path, sinceDate, callback) {

Expand All @@ -10,16 +34,31 @@ module.exports = function(path, sinceDate, callback) {
var updatedFiles = [],
count = 0;


var ignore = getIgnore(path, '.gitignore').concat(getCbdIgnore(path)).filter(function(search) {
return search.match(/\w+/);
})

ignore = _.map(ignore, function(search) {
return new RegExp('(^|[^\\w])' + search + '([^\\w]|$)');
})


exec(__dirname + '/mostRecent ' + Math.round(sinceDate/1000) + ' ' + path, { cwd: path }, function(err, stdout) {

if(err) return callback(err);

var files = [];

stdout.split(/[\n\r]+/g).forEach(function(file) {


if(!file.match(/\w+/g) || file.match(/\/(node_modules|\.)/)) return;


var intersect = ignore.filter(function(search) {
return search.test(file);
});


if(!file.match(/\w+/g) || file.match(/\/(node_modules|\.)/) || intersect.length) return;

file = file.substr(2);

Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -2,7 +2,7 @@
"author": "Craig Condon <craig@crcn.com>",
"name": "cupboard",
"description": "Reverse Repo System",
"version": "0.2.2",
"version": "0.2.3",
"repository": {
"type": "git",
"url": "git://github.com/crcn/cupboard.git"
Expand Down Expand Up @@ -31,4 +31,4 @@
},
"nexe-main": "./bin/cupboard.js",
"devDependencies": {}
}
}

0 comments on commit 601c24c

Please sign in to comment.