Comparing version 0.1.0 to 0.2.0
54
index.js
@@ -24,2 +24,3 @@ var fs = require('fs'); | ||
var index = 0; | ||
var filecount = files.length; | ||
var loop = function() { | ||
@@ -57,3 +58,3 @@ var filename = files[index]; | ||
index++; | ||
if(index === files.length) { | ||
if(index === filecount) { | ||
callback(null, filelist); | ||
@@ -65,3 +66,7 @@ } else { | ||
}; | ||
loop(); | ||
if(filecount > 0) { | ||
loop(); | ||
} else { | ||
callback(null, filelist); | ||
} | ||
} | ||
@@ -82,2 +87,3 @@ }); | ||
var index = 0; | ||
var filecount = files.length; | ||
var loop = function() { | ||
@@ -101,3 +107,3 @@ var filename = files[index]; | ||
index++; | ||
if(index === files.length) { | ||
if(index === filecount) { | ||
return filelist; | ||
@@ -108,3 +114,7 @@ } else { | ||
}; | ||
return loop(); | ||
if(filecount > 0) { | ||
return loop(); | ||
} else { | ||
return filelist; | ||
} | ||
}; | ||
@@ -116,2 +126,3 @@ return getfiles(this.from); | ||
var index = 0; | ||
var filecount = list.length; | ||
var loop = function() { | ||
@@ -123,3 +134,3 @@ mkdir(list[index], function(err) { | ||
index++; | ||
if(index === list.length) { | ||
if(index === filecount) { | ||
callback(null); | ||
@@ -132,3 +143,7 @@ } else { | ||
}; | ||
loop(); | ||
if(list.length > 0) { | ||
loop(); | ||
} else { | ||
callback(null); | ||
} | ||
}; | ||
@@ -138,6 +153,7 @@ | ||
var index = 0; | ||
var filecount = list.length; | ||
var loop = function() { | ||
mkdir.sync(list[index]); | ||
index++; | ||
if(index === list.length) { | ||
if(index === filecount) { | ||
return true; | ||
@@ -148,3 +164,7 @@ } else { | ||
}; | ||
return loop(); | ||
if(filecount > 0) { | ||
return loop(); | ||
} else { | ||
return true; | ||
} | ||
}; | ||
@@ -155,2 +175,3 @@ | ||
var index = 0; | ||
var filecount = list.length; | ||
var loop = function() { | ||
@@ -162,3 +183,3 @@ var filepath = list[index]; | ||
index++; | ||
if(index === list.length) { | ||
if(index === filecount) { | ||
callback(null); | ||
@@ -171,3 +192,7 @@ } else { | ||
}; | ||
loop(); | ||
if(filecount > 0) { | ||
loop(); | ||
} else { | ||
callback(null); | ||
} | ||
}; | ||
@@ -178,2 +203,3 @@ | ||
var index = 0; | ||
var filecount = list.length; | ||
var loop = function() { | ||
@@ -184,3 +210,3 @@ var filepath = list[index]; | ||
index++; | ||
if(index === list.length) { | ||
if(index === filecount) { | ||
return true; | ||
@@ -191,3 +217,7 @@ } else { | ||
}; | ||
return loop(); | ||
if(filecount > 0) { | ||
return loop(); | ||
} else { | ||
return true; | ||
} | ||
}; | ||
@@ -194,0 +224,0 @@ |
@@ -25,3 +25,3 @@ { | ||
}, | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"readmeFilename": "README.md", | ||
@@ -28,0 +28,0 @@ "bugs": { |
# copy-dir | ||
easy used 'copy-dir', copy a file or directory to anothor path, when distpath or parent distpath not exist, it will create the directory automatically. | ||
Easy used 'copy-dir' method, even use a filter, copy a file or directory to anothor path, when target path or parent target path not exists, it will create the directory automatically. | ||
@@ -27,5 +27,5 @@ # install | ||
It can use three arguments named stat, filepath, filename | ||
It can use three arguments named state, filepath, filename | ||
* stat: 'file' or 'directory', mark the file or path a file or directory | ||
* state: 'file' or 'directory', mark the file or path a file or directory | ||
* filepath: the file path | ||
@@ -41,3 +41,3 @@ * filename: the file name | ||
copydir.sync('/a/b/c', '/a/b/e'); | ||
copydir.sync('/my/from/path', '/my/target/path'); | ||
``` | ||
@@ -50,3 +50,3 @@ | ||
copydir('/a/b/c', '/a/b/e', function(err){ | ||
copydir('/my/from/path', '/my/target/path', function(err){ | ||
if(err){ | ||
@@ -70,14 +70,12 @@ console.log(err); | ||
copydir.sync('/a/b/c', '/a/b/e', function(stat, filepath, filename){ | ||
var status = true; | ||
if (stat === 'file' && path.extname(filepath) === '.html') { | ||
// copy files, but without .html | ||
status = false; | ||
} else if (stat === 'directory' && filename === '.svn') { | ||
// copy directories, but without .svn | ||
status = false; | ||
copydir.sync('/my/from/path', '/my/target/path', function(stat, filepath, filename){ | ||
if(stat === 'file' && path.extname(filepath) === '.html') { | ||
return false; | ||
} | ||
return status; | ||
if (stat === 'directory' && filename === '.svn') { | ||
return false; | ||
} | ||
return true; | ||
}, function(err){ | ||
console.log('ok') | ||
console.log('ok'); | ||
}); | ||
@@ -92,9 +90,15 @@ ``` | ||
copyDir('/a/b/c', '/a/b/e', function(stat, filepath, filename){ | ||
copydir('/a/b/c', '/a/b/e', function(stat, filepath, filename){ | ||
//... | ||
}, function(err) { | ||
//... | ||
}); | ||
``` | ||
## Questions? | ||
If you have any questions, please feel free to ask through [New Issue](https://github.com/pillys/copy-dir/issues/new). | ||
### License | ||
copy-dir is available under the terms of the [MIT](LICENSE) License. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9586
229
99
0