fix: linux文件拷贝错误抛出异常

This commit is contained in:
ZiuChen
2022-09-20 19:35:01 +08:00
parent f3c7d3899b
commit 8e681c7a75
2 changed files with 13 additions and 8 deletions

View File

@@ -22,9 +22,13 @@ class ClipboardEventListener extends EventEmitter {
const target = path.resolve(targetPath, 'clipboard-event-handler-linux')
const p = path.join(__dirname, 'platform/clipboard-event-handler-linux')
if(!existsSync(target)) {
mkdirSync(targetPath)
copyFileSync(p, target)
chmodSync(target, 0o755)
try {
mkdirSync(targetPath)
copyFileSync(p, target)
chmodSync(target, 0o755)
} catch (error) {
this.emit('error', error)
}
}
this.child = execFile(target);
}