Comparing version 1.0.0 to 1.0.1
@@ -8,2 +8,3 @@ // creates a zip file using either the native `zip` command if avaliable, | ||
var fs = require('fs'); | ||
var pathUtil = require('path'); | ||
@@ -40,2 +41,9 @@ var archiver = require('archiver'); | ||
function nodeZip(dest, source, done) { | ||
var zipDest = source;// this "dest" is the filename inside of the zip | ||
var basename = pathUtil.basename(source); | ||
if (basename == '*') { | ||
source = source.substr(0, source.length-1); | ||
zipDest = '/'; | ||
} | ||
var output = fs.createWriteStream(dest); | ||
@@ -48,6 +56,12 @@ var archive = archiver('zip'); | ||
archive.pipe(output); | ||
archive.bulk([ | ||
{expand: true, cwd: source, src: ['**'], dest: source} // this "dest" is the filename inside of the zip, not the name of the zip | ||
]); | ||
archive.finalize(); | ||
fs.stat(source, function(err, stats) { | ||
if (stats.isDirectory()) { | ||
archive.bulk([ | ||
{expand: true, cwd: source, src: ['**'], dest: zipDest} | ||
]); | ||
} else if (stats.isFile()) { | ||
archive.file(source, {name: basename, stats: stats}); | ||
} | ||
archive.finalize(); | ||
}); | ||
} | ||
@@ -54,0 +68,0 @@ |
{ | ||
"name": "bestzip", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Uses OS zip command if avaliable (for better performance and speed) or node.js version if there is no system command avaliable. Can be called via node or command line.", | ||
@@ -5,0 +5,0 @@ "main": "lib/bestzip.js", |
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
5837
85