Skip to content

Commit

Permalink
Make copy button work on android emulator in Linux using xsel
Browse files Browse the repository at this point in the history
Summary:
Resolves issue [#13165](#13165). The copy button in the redbox for RN android is not currently supported for Linux. This pull request provides the copy button functionality to Linux RN users.

I have tested the updated code locally.
Firstly, I edited `index.android.js` that caused the following error.
![pasted image at 2017_03_27 10_21 am](https://cloud.githubusercontent.com/assets/22376429/24426834/f567c5dc-13d6-11e7-8e3b-a650e2f6237c.png)
After I clicked the copy button and pasted from the clipboard into the chrome address bar, the message appeared.
![pasted_image_at_2017_03_27_10_21_am](https://cloud.githubusercontent.com/assets/22376429/24426896/2c0d4d64-13d7-11e7-8650-da19c44b177d.png)
Closes #13188

Differential Revision: D4819796

Pulled By: ericvicenti

fbshipit-source-id: 9adc6e93330f89240a505a403e4913dc10e5a31f
  • Loading branch information
saigrandhi authored and facebook-github-bot committed Apr 4, 2017
1 parent 058a540 commit 0fe0fc0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions local-cli/server/util/copyToClipBoard.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@

var child_process = require('child_process');
var spawn = child_process.spawn;
var path = require('path');
var fs = require('fs');

const xsel = path.join(__dirname, 'external/xsel');
fs.chmodSync(xsel, '0755');
/**
* Copy the content to host system clipboard.
* This is only supported on Mac and Windows for now.
Expand All @@ -25,6 +29,10 @@ function copyToClipBoard(content) {
var child = spawn('clip', []);
child.stdin.end(new Buffer(content, 'utf8'));
return true;
case 'linux':
var child = spawn(xsel, ['--clipboard', '--input']);
child.stdin.end(new Buffer(content, 'utf8'));
return true;
default:
return false;
}
Expand Down
Binary file added local-cli/server/util/external/xsel
Binary file not shown.

0 comments on commit 0fe0fc0

Please sign in to comment.