Skip to content

Commit

Permalink
Added noConflict function.
Browse files Browse the repository at this point in the history
  • Loading branch information
xavi- committed Sep 2, 2012
1 parent 2a4ab86 commit 7d186d0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions index.js
Expand Up @@ -19,7 +19,9 @@ switch(process.platform) {
break;
}

GLOBAL.copy = exports.copy = function(text) {
var _copy = GLOBAL.copy, _paste = GLOBAL.paste;

var copy = GLOBAL.copy = exports.copy = function(text) {
var child = spawn(config.copy.command, config.copy.args);

child
Expand All @@ -38,6 +40,16 @@ GLOBAL.copy = exports.copy = function(text) {
};

var pasteCommand = [ config.paste.command ].concat(config.paste.args).join(" ");
GLOBAL.paste = exports.paste = function() {
var paste = GLOBAL.paste = exports.paste = function() {
return execSync.stdout(pasteCommand);
};

exports.noConflict = function() {
GLOBAL.copy = _copy;
GLOBAL.paste = _paste;

if(_copy === undefined) { delete GLOBAL.copy; }
if(_paste === undefined) { delete GLOBAL.paste; }

return { copy: copy, paste: paste };
};

0 comments on commit 7d186d0

Please sign in to comment.