[Pkg-javascript-commits] [node-mv] 02/04: Imported Upstream version 2.0.3

Andrew Kelley andrewrk-guest at moszumanska.debian.org
Sat Jul 26 20:33:41 UTC 2014


This is an automated email from the git hooks/post-receive script.

andrewrk-guest pushed a commit to branch master
in repository node-mv.

commit 1223014e4ac718b675e03af6950be40fc33a0818
Author: Andrew Kelley <superjoe30 at gmail.com>
Date:   Sat Jul 26 20:27:03 2014 +0000

    Imported Upstream version 2.0.3
---
 LICENSE      | 21 +++++++++++++++++++++
 package.json |  9 ++++-----
 test/test.js | 41 ++++++++++++++++++++++-------------------
 3 files changed, 47 insertions(+), 24 deletions(-)

diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..e57596d
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+Copyright (c) 2014 Andrew Kelley
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation files
+(the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicense, and/or sell copies of the Software,
+and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/package.json b/package.json
index e507676..36ea2d2 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "mv",
-  "version": "2.0.1",
+  "version": "2.0.3",
   "description": "fs.rename but works across devices. same as the unix utility 'mv'",
   "main": "index.js",
   "scripts": {
@@ -19,17 +19,16 @@
     "folder"
   ],
   "author": "Andrew Kelley",
-  "license": "BSD",
+  "license": "MIT",
   "engines": {
     "node": ">=0.8.0"
   },
   "devDependencies": {
-    "mocha": "~1.20.1",
-    "proxyquire": "~1.0.1"
+    "mocha": "~1.21.0"
   },
   "dependencies": {
     "mkdirp": "~0.5.0",
-    "ncp": "~0.5.1",
+    "ncp": "~0.6.0",
     "rimraf": "~2.2.8"
   },
   "bugs": {
diff --git a/test/test.js b/test/test.js
index ce0d528..f80821a 100644
--- a/test/test.js
+++ b/test/test.js
@@ -1,22 +1,28 @@
 var assert = require('assert');
-var proxyquire = require('proxyquire');
 var fs = require('fs');
 var rimraf = require('rimraf');
+var describe = global.describe;
+var it = global.it;
+var mv = require('../');
 
-describe("mv", function() {
+var realFsRename = fs.rename;
+function overrideFsRename() {
   // makes fs.rename return cross-device error.
-  var mock_fs = {};
-  mock_fs.rename = function(src, dest, cb) {
+  fs.rename = function(src, dest, cb) {
     setTimeout(function() {
       var err = new Error();
       err.code = 'EXDEV';
       cb(err);
     }, 10);
   };
+}
 
-  it("should rename a file on the same device", function (done) {
-    var mv = proxyquire('../index', {});
+function restoreFsRename() {
+  fs.rename = realFsRename;
+}
 
+describe("mv", function() {
+  it("should rename a file on the same device", function (done) {
     mv("test/a-file", "test/a-file-dest", function (err) {
       assert.ifError(err);
       fs.readFile("test/a-file-dest", 'utf8', function (err, contents) {
@@ -29,8 +35,6 @@ describe("mv", function() {
   });
 
   it("should not overwrite if clobber = false", function (done) {
-    var mv = proxyquire('../index', {});
-
     mv("test/a-file", "test/a-folder/another-file", {clobber: false}, function (err) {
       assert.ok(err && err.code === 'EEXIST', "throw EEXIST");
       done();
@@ -38,8 +42,6 @@ describe("mv", function() {
   });
 
   it("should not create directory structure by default", function (done) {
-    var mv = proxyquire('../index', {});
-
     mv("test/a-file", "test/does/not/exist/a-file-dest", function (err) {
       assert.strictEqual(err.code, 'ENOENT');
       done();
@@ -47,8 +49,6 @@ describe("mv", function() {
   });
 
   it("should create directory structure when mkdirp option set", function (done) {
-    var mv = proxyquire('../index', {});
-
     mv("test/a-file", "test/does/not/exist/a-file-dest", {mkdirp: true}, function (err) {
       assert.ifError(err);
       fs.readFile("test/does/not/exist/a-file-dest", 'utf8', function (err, contents) {
@@ -64,21 +64,22 @@ describe("mv", function() {
   });
 
   it("should work across devices", function (done) {
-    var mv = proxyquire('../index', {fs: mock_fs});
+    overrideFsRename();
     mv("test/a-file", "test/a-file-dest", function (err) {
       assert.ifError(err);
       fs.readFile("test/a-file-dest", 'utf8', function (err, contents) {
         assert.ifError(err);
         assert.strictEqual(contents, "sonic the hedgehog\n");
         // move it back
-        mv("test/a-file-dest", "test/a-file", done);
+        mv("test/a-file-dest", "test/a-file", function(err) {
+          restoreFsRename();
+          done(err);
+        });
       });
     });
   });
 
   it("should move folders", function (done) {
-    var mv = proxyquire('../index', {});
-
     mv("test/a-folder", "test/a-folder-dest", function (err) {
       assert.ifError(err);
       fs.readFile("test/a-folder-dest/another-file", 'utf8', function (err, contents) {
@@ -91,15 +92,17 @@ describe("mv", function() {
   });
 
   it("should move folders across devices", function (done) {
-    var mv = proxyquire('../index', {fs: mock_fs});
-
+    overrideFsRename();
     mv("test/a-folder", "test/a-folder-dest", function (err) {
       assert.ifError(err);
       fs.readFile("test/a-folder-dest/another-folder/file3", 'utf8', function (err, contents) {
         assert.ifError(err);
         assert.strictEqual(contents, "knuckles\n");
         // move it back
-        mv("test/a-folder-dest", "test/a-folder", done);
+        mv("test/a-folder-dest", "test/a-folder", function(err) {
+          restoreFsRename();
+          done(err);
+        });
       });
     });
   });

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-mv.git



More information about the Pkg-javascript-commits mailing list