Permalink
Browse files

add preventRecursiveFunction for each method

  • Loading branch information...
1 parent 435e212 commit f3045cad93bcb197ba5ccb18d3ff14b6926fd1a8 @colorhook committed Jan 10, 2013
Showing with 19 additions and 29 deletions.
  1. +3 −0 .travis.yml
  2. +8 −23 lib/fileutil.js
  3. +8 −1 package.json
  4. +0 −5 test/fileutil.js
View
@@ -0,0 +1,3 @@
+language: node_js
+node_js:
+ - 0.8
View
@@ -38,7 +38,6 @@ var copyFile = function(src, dest){
var fu = require('file-util');
- fu.absolute(file); //绝对路径
fu.exist(file); //是否存在
fu.copy(file, 'new-path'); //复制到某个新目录
fu.move(file, 'new-path'); //移动到某个新目录
@@ -80,24 +79,7 @@ var copyFile = function(src, dest){
var fu = {
- /**
- 返回绝对地址
- @method absolute
- @static
- @param {String} f 文件名称
- @param {String} (optional) dir 文件目录
- @return String 文件的绝对地址
- @example
- console.log(fu.absolute('src/app.js'));
- console.log(fu.absolte('app.js', 'src'));
- **/
- absolute: function(f, dir){
- if(dir != undefined){
- f = path.relative(dir, f);
- }
- return path.resolve(f);
- },
/**
判断某个或某些文件(夹)是否存在
@@ -515,6 +497,7 @@ var fu = {
var excludeDirectory = options.excludeDirectory;
var matchFunction = options.matchFunction;
var breakFunction = options.breakFunction;
+ var preventRecursiveFunction = options.preventRecursiveFunction;
var recursive = true;
var checkCount = 0;
var p, i, l;
@@ -545,11 +528,13 @@ var fu = {
if (isDir) {
if (recursive) {
- checkCount++;
- self.each(name, callback, options, function(){
- checkCount--;
- onFinished();
- });
+ if(!preventRecursiveFunction || !preventRecursiveFunction(info)){
+ checkCount++;
+ self.each(name, callback, options, function(){
+ checkCount--;
+ onFinished();
+ });
+ }
}
if (!excludeDirectory) {
View
@@ -1,6 +1,6 @@
{
"name": "fileutil",
- "version": "1.0.0",
+ "version": "1.1.0",
"description": "an easy file operation utility",
"keywords": ["synchronous file operation", "touch, move, mkdir, copy"],
"main": "lib/fileutil.js",
@@ -20,6 +20,13 @@
"dependencies": {
"wrench": "~1.4.4"
},
+ "devDependencies: {
+ "mocha": "~1.7.4",
+ "should": "~1.2.1"
+ },
+ "scripts":{
+ "test": "mocha --reporter spec --timeout 5000--require should"
+ },
"homepage": "https://github.com/colorhook/fileutil",
"repository" : {
"type" : "git",
View
@@ -9,11 +9,6 @@ describe('file is a static utility', function(){
fu.delete('tmp2');
});
- it('absolute method to an absolute path', function(){
- var f = __filename;
- fu.absolute(f).should.equal(path.resolve(f));
- fu.absolute(f, __dirname + '/../').should.equal(path.resolve(f));
- });
it('exist method return if a file or dir exist', function(){
var f = __filename;

0 comments on commit f3045ca

Please sign in to comment.