mirror of
https://github.com/ZiuChen/ClipboardManager.git
synced 2025-06-07 22:04:06 +08:00
fix: use chmodSync modify file permission dynamically
This commit is contained in:
parent
87d56fa2f3
commit
19f6d1867d
18
public/node_modules/clipboard-event/index.js
generated
vendored
18
public/node_modules/clipboard-event/index.js
generated
vendored
@ -1,3 +1,4 @@
|
|||||||
|
const { chmodSync } = require('fs');
|
||||||
const { EventEmitter } = require('events');
|
const { EventEmitter } = require('events');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { execFile } = require('child_process');
|
const { execFile } = require('child_process');
|
||||||
@ -9,11 +10,20 @@ class ClipboardEventListener extends EventEmitter {
|
|||||||
}
|
}
|
||||||
startListening() {
|
startListening() {
|
||||||
const { platform } = process;
|
const { platform } = process;
|
||||||
const file = `platform/clipboard-event-handler-${platform}${platform === 'win32' ? '.exe' : ''}`
|
if (platform === 'win32') {
|
||||||
if(platform !== 'win32' && platform !== 'darwin' && platform !== 'linux') {
|
this.child = execFile(path.join(__dirname, 'platform/clipboard-event-handler-win32.exe'));
|
||||||
throw new Error(`ClipboardEventListener is not supported on ${platform}`);
|
}
|
||||||
|
else if (platform === 'linux') {
|
||||||
|
const p = path.join(__dirname, 'platform/clipboard-event-handler-linux');
|
||||||
|
chmodSync(p, 0o111); // modify file permission: everyone can execute, or it will fail
|
||||||
|
this.child = execFile();
|
||||||
|
}
|
||||||
|
else if (platform === 'darwin') {
|
||||||
|
this.child = execFile(path.join(__dirname, 'platform/clipboard-event-handler-mac'));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw 'Not yet supported';
|
||||||
}
|
}
|
||||||
this.child = execFile(path.join(__dirname, file));
|
|
||||||
this.child.stdout.on('data', (data) => {
|
this.child.stdout.on('data', (data) => {
|
||||||
if (data.trim() === 'CLIPBOARD_CHANGE') {
|
if (data.trim() === 'CLIPBOARD_CHANGE') {
|
||||||
this.emit('change');
|
this.emit('change');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user