Comparing version 0.2.0 to 1.0.0
13
index.js
@@ -11,3 +11,3 @@ var async = require('async') | ||
var pruneToCount = function(count, dirs, cb) { | ||
// count >= dirs.length means prune nothing | ||
@@ -18,7 +18,2 @@ if (count >= dirs.length) { | ||
// count of 0 means prune everything | ||
if (count === 0) { | ||
count = dirs.length | ||
} | ||
// sort by mtime, oldest first | ||
@@ -29,4 +24,6 @@ dirs = dirs.sort(function(a, b) { | ||
// trim to *count* entries | ||
dirs = dirs.slice(0, count) | ||
// trim all but *count* newest entries | ||
if (count !== 0) { | ||
dirs = dirs.slice(0, -count) | ||
} | ||
@@ -33,0 +30,0 @@ // delete *count* oldest directories |
{ | ||
"name": "dirkeeper", | ||
"version": "0.2.0", | ||
"version": "1.0.0", | ||
"description": "Prune a directory to contain a set number of sub-directories, retention policy is recency", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -127,8 +127,10 @@ var async = require('async') | ||
fs.readdir(TEN_SUBDIRS, function(err, origFiles) { | ||
keeper({ baseDir: TEN_SUBDIRS, count: 5 }, function(err) { | ||
keeper({ baseDir: TEN_SUBDIRS, count: 3 }, function(err) { | ||
fs.readdir(TEN_SUBDIRS, function(err, files) { | ||
var dirs = filterDirs(TEN_SUBDIRS, files) | ||
expect(dirs).to.have.length(5) | ||
expect(dirs).to.have.length(3) | ||
// the earliest dir names are the oldest. see makeDirs(). | ||
expect(dirs).to.not.contain(['tmpfile.0', 'tmpfile.1', 'tmpfile.2', 'tmpfile.3', 'tmpfile.4']) | ||
expect(dirs).to.not.contain([ | ||
'tmpfile.0', 'tmpfile.1', 'tmpfile.2', 'tmpfile.3', 'tmpfile.4', 'tmpfile.5', 'tmpfile.6', | ||
]) | ||
done() | ||
@@ -135,0 +137,0 @@ }) |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
8419
6
1