[Pkg-javascript-commits] [node-tmp] 01/03: Imported Upstream version 0.0.27
Ross Gammon
ross-guest at moszumanska.debian.org
Wed Aug 19 19:50:59 UTC 2015
This is an automated email from the git hooks/post-receive script.
ross-guest pushed a commit to branch master
in repository node-tmp.
commit f85cc05b20855743294de73b6001ad745f757f36
Author: Ross Gammon <rossgammon at mail.dk>
Date: Wed Aug 19 21:31:42 2015 +0200
Imported Upstream version 0.0.27
---
README.md | 8 +++-----
lib/tmp.js | 21 ++++++++++++++-------
package.json | 9 ++-------
test/dir-test.js | 8 +++++++-
4 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/README.md b/README.md
index 2e9da33..ba29a2a 100644
--- a/README.md
+++ b/README.md
@@ -6,10 +6,8 @@ A simple temporary file and directory creator for [node.js.][1]
## About
-The main difference between bruce's [node-temp][2] is that mine more
-aggressively checks for the existence of the newly created temporary file and
-creates the new file with `O_EXCL` instead of simple `O_CREAT | O_RDRW`, so it
-is safer.
+This is a [widely used library][2] to create temporary files and directories
+in a [node.js][1] environment.
Tmp offers both an asynchronous and a synchronous API. For all API calls, all
the parameters are optional.
@@ -264,5 +262,5 @@ All options are optional :)
* `unsafeCleanup`: recursively removes the created temporary directory, even when it's not empty. default is `false`
[1]: http://nodejs.org/
-[2]: https://github.com/bruce/node-temp
+[2]: https://www.npmjs.com/browse/depended/tmp
[3]: http://www.kernel.org/doc/man-pages/online/pages/man3/mkstemp.3.html
diff --git a/lib/tmp.js b/lib/tmp.js
index b7c3044..50d696d 100644
--- a/lib/tmp.js
+++ b/lib/tmp.js
@@ -343,7 +343,18 @@ function _createTmpDirSync(options) {
*/
function _prepareTmpFileRemoveCallback(name, fd, opts) {
var removeCallback = _prepareRemoveCallback(function _removeCallback(fdPath) {
- fs.closeSync(fdPath[0]);
+ try {
+ fs.closeSync(fdPath[0]);
+ }
+ catch (e) {
+ // under some node/windows related circumstances, a temporary file
+ // may have not be created as expected or the file was already closed
+ // by the user, in which case we will simply ignore the error
+ if (e.errno != -_c.EBADF && e.errno != -c.ENOENT) {
+ // reraise any unanticipated error
+ throw e;
+ }
+ }
fs.unlinkSync(fdPath[1]);
}, [fd, name]);
@@ -363,12 +374,8 @@ function _prepareTmpFileRemoveCallback(name, fd, opts) {
* @returns {Function} the callback
*/
function _prepareTmpDirRemoveCallback(name, opts) {
-
- var removeCallback = _prepareRemoveCallback(
- opts.unsafeCleanup
- ? _rmdirRecursiveSync
- : fs.rmdirSync.bind(fs),
- name);
+ var removeFunction = opts.unsafeCleanup ? _rmdirRecursiveSync : fs.rmdirSync.bind(fs);
+ var removeCallback = _prepareRemoveCallback(removeFunction, name);
if (!opts.keep) {
_removeObjects.unshift(removeCallback);
diff --git a/package.json b/package.json
index ac42441..5344814 100644
--- a/package.json
+++ b/package.json
@@ -1,18 +1,13 @@
{
"name": "tmp",
- "version": "0.0.26",
+ "version": "0.0.27",
"description": "Temporary file and directory creator",
"author": "KARASZI István <github at spam.raszi.hu> (http://raszi.hu/)",
"homepage": "http://github.com/raszi/node-tmp",
"keywords": [ "temporary", "tmp", "temp", "tempdir", "tempfile", "tmpdir", "tmpfile" ],
- "licenses": [
- {
- "type": "MIT",
- "url": "http://opensource.org/licenses/MIT"
- }
- ],
+ "license": "MIT",
"repository": {
"type": "git",
diff --git a/test/dir-test.js b/test/dir-test.js
index 363eecc..1a5739f 100644
--- a/test/dir-test.js
+++ b/test/dir-test.js
@@ -189,7 +189,13 @@ vows.describe('Directory creation').addBatch({
'should not return with an error': assert.isNull,
'should return with a name': Test.assertName,
- 'should be a directory': _testDir(040700)
+ 'should be a directory': function (err, name) {
+ _testDir(040700)(err, name);
+ // make sure that everything gets cleaned up
+ fs.unlinkSync(path.join(name, 'should-be-removed.file'));
+ fs.unlinkSync(path.join(name, 'symlinkme-target'));
+ fs.rmdirSync(name);
+ }
},
'remove callback': {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-tmp.git
More information about the Pkg-javascript-commits
mailing list