rightclick
Advanced tools
Comparing version 0.5.0 to 0.6.0
# rightClick Changelog | ||
### 31 March 2014, 0.6.0 | ||
* Copy & Cut now accept optional suffix argument | ||
### 28 March 2014, 0.5.0 | ||
@@ -4,0 +8,0 @@ |
var fs = require('fs'), | ||
path = require('path'); | ||
module.exports = function (docPath) { | ||
module.exports = function (docPath, suffix) { | ||
@@ -13,5 +13,8 @@ docPath = docPath || []; | ||
if (typeof docPath === 'string') { | ||
docPath = [docPath]; | ||
} | ||
// Same for suffix | ||
if (typeof suffix === 'string') { | ||
suffix = [suffix]; | ||
} | ||
@@ -45,4 +48,11 @@ | ||
// Copy file content to clipboard. | ||
clip[docPath] = fs.readFileSync(fullPath, enc); | ||
if (suffix) { | ||
var fileSuffix = new RegExp(docPath.split(/\./).pop()); | ||
if (fileSuffix.test(suffix)) { | ||
clip[docPath] = fs.readFileSync(fullPath, enc); | ||
} | ||
} else { | ||
// Copy file content to clipboard. | ||
clip[docPath] = fs.readFileSync(fullPath, enc); | ||
} | ||
@@ -49,0 +59,0 @@ } |
@@ -1,4 +0,4 @@ | ||
module.exports = function (docPath) { | ||
module.exports = function (docPath, suffix) { | ||
this.copy(docPath).del(docPath); | ||
this.copy(docPath, suffix).del(docPath); | ||
@@ -5,0 +5,0 @@ return this; |
{ | ||
"name": "rightclick", | ||
"description": "Cut, copy, paste and delete for node.js", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "cut", |
@@ -36,2 +36,8 @@ # rightClick [](http://travis-ci.org/mattyod/rightClick) | ||
As of version 0.6.0 cut now accepts an optional suffix argument which can be either a string or an array. If given rightClick will cut files with the given suffix. | ||
The following would only cut files with the suffix .js & .css from within subFolder. | ||
rightClick('./folder').cut(['subFolder'], ['js', 'css']) | ||
### copy() | ||
@@ -51,2 +57,8 @@ | ||
As of version 0.6.0 copy now accepts an optional suffix argument which can be either a string or an array. If given rightClick will copy files with the given suffix. | ||
The following would only copy files with the suffix .js & .css from within subFolder. | ||
rightClick('./folder').copy(['subFolder'], ['js', 'css']) | ||
### paste() | ||
@@ -53,0 +65,0 @@ |
@@ -101,4 +101,24 @@ // Helper modules | ||
}, | ||
'copy with suffix': function (test) { | ||
test.expect(3); | ||
// Call tested module | ||
this.rightClick().copy('mixed', ['txt', 'js']); | ||
test.equal(this.clipboard.files.mixed['text.txt'].toString(), 'text file\n', | ||
'Text (.txt) file has been copied'); | ||
test.equal(this.clipboard.files.mixed['javascript.js'].toString(), 'console.log(\'a\');\n', | ||
'JavaScript (.js) file has been copied'); | ||
test.equal(this.clipboard.files.mixed['other.rb'], undefined, | ||
'Other file has not been copied'); | ||
test.done(); | ||
} | ||
}; |
@@ -13,3 +13,4 @@ // Helper modules | ||
'./test/sandbox/cut/deep/deeper/': null, | ||
'./test/sandbox/cut/deep/deeper/file.txt': 'ccc' | ||
'./test/sandbox/cut/deep/deeper/file.txt': 'ccc', | ||
'./test/sandbox/cut/deep/other.rb': 'xxx' | ||
}; | ||
@@ -23,2 +24,3 @@ | ||
'./test/sandbox/cut/deep/file.txt', | ||
'./test/sandbox/cut/deep/other.rb', | ||
'./test/sandbox/cut/deep' | ||
@@ -66,3 +68,3 @@ ]; | ||
test.expect(5); | ||
test.expect(6); | ||
@@ -86,2 +88,5 @@ // Call tested module | ||
test.equal(that.clipboard.files.deep['other.rb'].toString(), 'xxx', | ||
'The file is available on the clipboard'); | ||
test.ok(typeof that.clipboard.files.deep.deeper === 'object', | ||
@@ -95,4 +100,20 @@ 'Folder object has been created on the clipboard for deeper'); | ||
}, | ||
'cut with suffix': function (test) { | ||
test.expect(2); | ||
// Call tested module | ||
var that = rightClick('./test/sandbox/cut/').cut('deep', ['txt']); | ||
test.equal(that.clipboard.files.deep['file.txt'].toString(), 'bbb', | ||
'The file is available on the clipboard'); | ||
test.equal(that.clipboard.files.deep['other.rb'], undefined, | ||
'The file has not been cut'); | ||
test.done(); | ||
} | ||
}; | ||
}; |
25486
520
105