Permalink
Browse files

Support copy to clipboard on Windows

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 10a29aa95438d1f65739fa91b608f29779c2d5c1
Showing with 8 additions and 1 deletion.
  1. +3 −0 local-cli/.eslintrc
  2. +5 −1 local-cli/server/util/copyToClipBoard.js
View
@@ -2,5 +2,8 @@
"rules": {
"extra-arrow-initializer": 0,
"no-console-disallow": 0
+ },
+ "env": {
+ "node": true
}
}
@@ -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;
}

0 comments on commit 10a29aa

Please sign in to comment.