rightclick
Advanced tools
Comparing version 0.4.4 to 0.5.0
# rightClick Changelog | ||
### 28 March 2014, 0.5.0 | ||
* Paste now accepts optional force argument | ||
### 28 March 2014, 0.4.4 | ||
@@ -4,0 +8,0 @@ |
@@ -5,7 +5,7 @@ var fs = require('fs'), | ||
module.exports = function (target) { | ||
module.exports = function (target, force) { | ||
var check = function (target) { | ||
if (fs.existsSync(target)) { | ||
if (!force && fs.existsSync(target)) { | ||
@@ -37,3 +37,5 @@ log.error(target + ' already exists.'); | ||
fs.mkdirSync(newTarget); | ||
if (!fs.existsSync(newTarget)) { | ||
fs.mkdirSync(newTarget); | ||
} | ||
@@ -40,0 +42,0 @@ paste(newTarget, clip[item]); |
{ | ||
"name": "rightclick", | ||
"description": "Cut, copy, paste and delete for node.js", | ||
"version": "0.4.4", | ||
"version": "0.5.0", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "cut", |
@@ -60,2 +60,6 @@ # rightClick [](http://travis-ci.org/mattyod/rightClick) | ||
As of version 0.5.0 paste now accepts an optional force boolean. This will allow you to paste over existing folders. i.e. | ||
rightClick('./myParentFolder').copy('myFolder').paste('myNewDestination', true); | ||
### del() | ||
@@ -62,0 +66,0 @@ |
@@ -63,3 +63,3 @@ // Helper modules | ||
paste: function (test) { | ||
test.expect(8); | ||
test.expect(11); | ||
@@ -93,2 +93,40 @@ // Call tested method. | ||
// Redefining rightClick clipboard for force | ||
this.rightClick = function () { | ||
this.clipboard = { | ||
target: '', | ||
files: { | ||
'file.txt': 'foo', | ||
'deep': { | ||
'file.txt': 'bar', | ||
'deeper': { | ||
'file.txt': 'baz' | ||
} | ||
} | ||
} | ||
}; | ||
// The tested module. | ||
this.paste = require('../lib/paste'); | ||
return this; | ||
}; | ||
// Call tested method with force. | ||
this.rightClick().paste('./test/sandbox/paste', true); | ||
test.strictEqual(fs.readFileSync(unPrepObject[0], 'binary'), 'baz', | ||
'file.txt has been over written with force'); | ||
test.strictEqual(fs.readFileSync(unPrepObject[2], 'binary'), 'bar', | ||
'deep/file.txt has been over written with force'); | ||
test.strictEqual(fs.readFileSync(unPrepObject[4], 'binary'), 'foo', | ||
'deep/deeper/file.txt been over written with force'); | ||
test.done(); | ||
@@ -95,0 +133,0 @@ |
Sorry, the diff of this file is not supported yet
23286
482
93