diff options
-rw-r--r-- | node_modules/fs-vacuum/package.json | 11 | ||||
-rw-r--r-- | node_modules/fs-vacuum/vacuum.js | 17 | ||||
-rw-r--r-- | package.json | 2 |
3 files changed, 17 insertions, 13 deletions
diff --git a/node_modules/fs-vacuum/package.json b/node_modules/fs-vacuum/package.json index dc1516dbb..559b7bf2b 100644 --- a/node_modules/fs-vacuum/package.json +++ b/node_modules/fs-vacuum/package.json @@ -1,6 +1,6 @@ { "name": "fs-vacuum", - "version": "1.2.2", + "version": "1.2.5", "description": "recursively remove empty directories -- to a point", "main": "vacuum.js", "scripts": { @@ -31,12 +31,13 @@ }, "dependencies": { "graceful-fs": "^3.0.2", + "path-is-inside": "^1.0.1", "rimraf": "^2.2.8" }, "readme": "# fs-vacuum\n\nRemove the empty branches of a directory tree, optionally up to (but not\nincluding) a specified base directory. Optionally nukes the leaf directory.\n\n## Usage\n\n```javascript\nvar logger = require(\"npmlog\");\nvar vacuum = require(\"fs-vacuum\");\n\nvar options = {\n base : \"/path/to/my/tree/root\",\n purge : true,\n log : logger.silly.bind(logger, \"myCleanup\")\n};\n\n/* Assuming there are no other files or directories in \"out\", \"to\", or \"my\",\n * the final path will just be \"/path/to/my/tree/root\".\n */\nvacuum(\"/path/to/my/tree/root/out/to/my/files\", function (error) {\n if (error) console.error(\"Unable to cleanly vacuum:\", error.message);\n});\n```\n# vacuum(directory, options, callback)\n\n* `directory` {String} Leaf node to remove. **Must be a directory, symlink, or file.**\n* `options` {Object}\n * `base` {String} No directories at or above this level of the filesystem will be removed.\n * `purge` {Boolean} If set, nuke the whole leaf directory, including its contents.\n * `log` {Function} A logging function that takes `npmlog`-compatible argument lists.\n* `callback` {Function} Function to call once vacuuming is complete.\n * `error` {Error} What went wrong along the way, if anything.\n", "readmeFilename": "README.md", - "gitHead": "c788fcc30fe8e73725f4f202d86c51d23d9f3378", - "_id": "fs-vacuum@1.2.2", - "_shasum": "0e26ca2b14eb4ceb4b590a92aad585756ed18e40", - "_from": "fs-vacuum@>=1.2.2 <1.3.0" + "gitHead": "4911a38a65b6a6cb19fc980d18304e1cfca91fbf", + "_id": "fs-vacuum@1.2.5", + "_shasum": "a5cbaa844b4b3a7cff139f3cc90e7f7007e5fbb8", + "_from": "fs-vacuum@~1.2.5" } diff --git a/node_modules/fs-vacuum/vacuum.js b/node_modules/fs-vacuum/vacuum.js index 5880ae73d..e55abe970 100644 --- a/node_modules/fs-vacuum/vacuum.js +++ b/node_modules/fs-vacuum/vacuum.js @@ -1,6 +1,7 @@ -var assert = require("assert") -var dirname = require("path").dirname -var resolve = require("path").resolve +var assert = require("assert") +var dirname = require("path").dirname +var resolve = require("path").resolve +var isInside = require("path-is-inside") var rimraf = require("rimraf") var lstat = require("graceful-fs").lstat @@ -19,9 +20,10 @@ function vacuum(leaf, options, cb) { var log = options.log ? options.log : function () {} - var base = options.base - if (base && resolve(leaf).indexOf(resolve(base)) !== 0) { - return cb(new Error(resolve(leaf) + " is not a child of " + resolve(base))) + leaf = leaf && resolve(leaf) + var base = options.base && resolve(options.base) + if (base && !isInside(leaf, base)) { + return cb(new Error(leaf + " is not a child of " + base)) } lstat(leaf, function (error, stat) { @@ -59,8 +61,9 @@ function vacuum(leaf, options, cb) { }) function next(branch) { + branch = branch && resolve(branch) // either we've reached the base or we've reached the root - if ((base && resolve(branch) === resolve(base)) || branch === dirname(branch)) { + if ((base && branch === base) || branch === dirname(branch)) { log("finished vacuuming up to", branch) return cb(null) } diff --git a/package.json b/package.json index 4ead705e7..5e959c29c 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "config-chain": "~1.1.8", "dezalgo": "~1.0.1", "editor": "~0.1.0", - "fs-vacuum": "~1.2.2", + "fs-vacuum": "~1.2.5", "fs-write-stream-atomic": "~1.0.2", "fstream": "~1.0.3", "fstream-npm": "~1.0.1", |