Permalink
Browse files

Added silent method that suppresses all console.log's. #7

  • Loading branch information...
1 parent f719ab3 commit 063d7442a727b5a6f31a66818d9e07dc7f85d2a6 @xavi- committed Feb 24, 2014
Showing with 10 additions and 5 deletions.
  1. +10 −5 index.js
View
15 index.js
@@ -9,7 +9,7 @@ try {
}
catch(e) { execSync = null; }
-var config;
+var config, isSilent;
switch(process.platform) {
case "darwin":
@@ -34,7 +34,7 @@ var copy = GLOBAL.copy = exports.copy = function(text, cb) {
child
.on("exit", function() {
if(cb) { cb(null, text); }
- else { console.log("Copy complete"); }
+ else if(!isSilent) { console.log("Copy complete"); }
})
.on("error", function(err) { cb(err); })
.stderr
@@ -44,7 +44,7 @@ var copy = GLOBAL.copy = exports.copy = function(text, cb) {
var error = err.join("");
if(cb) { cb(error); }
- else { console.log(error); }
+ else if(!isSilent) { console.log(error); }
})
;
@@ -80,7 +80,7 @@ var paste = GLOBAL.paste = exports.paste = function(cb) {
cb(err.join(""));
})
;
- } else {
+ } else if(!isSilent) {
console.error(
"Unfortunately a synchronous version of paste is not supported on this platform."
);
@@ -94,5 +94,10 @@ exports.noConflict = function() {
if(_copy === undefined) { delete GLOBAL.copy; }
if(_paste === undefined) { delete GLOBAL.paste; }
- return { copy: copy, paste: paste };
+ return exports;
};
+
+exports.silent = function() {
+ isSilent = true;
+ return exports;
+};

0 comments on commit 063d744

Please sign in to comment.