mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Make copy button work on android emulator in Linux using xsel
Summary: Resolves issue [#13165](https://github.com/facebook/react-native/issues/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.  After I clicked the copy button and pasted from the clipboard into the chrome address bar, the message appeared.  Closes https://github.com/facebook/react-native/pull/13188 Differential Revision: D4819796 Pulled By: ericvicenti fbshipit-source-id: 9adc6e93330f89240a505a403e4913dc10e5a31f
This commit is contained in:
committed by
Facebook Github Bot
parent
058a5406ba
commit
0fe0fc038b
@@ -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.
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
BIN
local-cli/server/util/external/xsel
vendored
Executable file
BIN
local-cli/server/util/external/xsel
vendored
Executable file
Binary file not shown.
Reference in New Issue
Block a user