Skip to content

Commit

Permalink
Support copy to clipboard on Windows
Browse files Browse the repository at this point in the history
Summary:
Also fix lint errors about Buffer being undefined by adding env: node to the eslint config for local-cli.

Tested on windows 10.
Closes #11959

Differential Revision: D4438903

Pulled By: hramos

fbshipit-source-id: 28d5edd662dd1e63dedf1274ff0a21af4df84f5e
  • Loading branch information
janicduplessis authored and facebook-github-bot committed Jan 20, 2017
1 parent 81193eb commit 10a29aa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions local-cli/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"rules": {
"extra-arrow-initializer": 0,
"no-console-disallow": 0
},
"env": {
"node": true
}
}
6 changes: 5 additions & 1 deletion local-cli/server/util/copyToClipBoard.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ var spawn = child_process.spawn;

/**
* Copy the content to host system clipboard.
* This is only supported on Mac for now.
* This is only supported on Mac and Windows for now.
*/
function copyToClipBoard(content) {
switch (process.platform) {
case 'darwin':
var child = spawn('pbcopy', []);
child.stdin.end(new Buffer(content, 'utf8'));
return true;
case 'win32':
var child = spawn('clip', []);
child.stdin.end(new Buffer(content, 'utf8'));
return true;
default:
return false;
}
Expand Down

0 comments on commit 10a29aa

Please sign in to comment.