prostore.glob-utils
Advanced tools
Comparing version 0.0.1 to 0.0.2
47
index.js
'use strict'; | ||
var glob = require('glob'); | ||
var glob = require('glob') | ||
, async = require('async') | ||
, fs = require('fs') | ||
, path = require('path') | ||
, crypto = require('crypto'); | ||
module.exports = exports = function(cwd, pattern, cb) { | ||
var files = []; | ||
var g = new glob.Glob(pattern, { | ||
cwd: cwd, | ||
nodir: true, | ||
stat: true | ||
glob(pattern, { cwd: cwd, nodir: true }, function(err, files) { | ||
/* istanbul ignore if */ | ||
if (err) return cb(err); | ||
async.map(files, function(file, cb) { | ||
var filename = path.resolve(cwd, file); | ||
fs.stat(filename, function(err, stat) { | ||
/* istanbul ignore if */ | ||
if (err) return cb(err); | ||
var hash = crypto.createHash('md5') | ||
, stream = fs.createReadStream(filename, 'utf-8'); | ||
stream.on('data', function(data) { | ||
hash.update(data); | ||
}); | ||
stream.on('error', function(err) { | ||
cb(err); | ||
}); | ||
stream.on('end', function() { | ||
cb(null, { | ||
path: file, | ||
md5: hash.digest('hex'), | ||
mtime: stat.mtime.getTime() | ||
}); | ||
}); | ||
}); | ||
}, cb); | ||
}); | ||
g.on('stat', function(file, stat) { | ||
files.push({ | ||
path: file, | ||
mtime: stat.mtime.getTime() | ||
}); | ||
}); | ||
g.on('end', function() { | ||
cb(null, files); | ||
}); | ||
}; | ||
@@ -36,3 +51,3 @@ | ||
} | ||
if (srcFile.mtime < dstFile.mtime) | ||
if (srcFile.md5 && srcFile.md5 == dstFile.md5) | ||
unmodified.push(dstFile); | ||
@@ -39,0 +54,0 @@ else |
{ | ||
"name": "prostore.glob-utils", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Glob Utilities", | ||
"main": "index.js", | ||
"dependencies": { | ||
"glob": "*" | ||
"glob": "*", | ||
"async": "*" | ||
}, | ||
@@ -9,0 +10,0 @@ "repository": { |
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
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
2474
66
2
4
1
+ Addedasync@*
+ Addedasync@3.2.6(transitive)