-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
435f4e2
commit d417dc0
Showing
7 changed files
with
45 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
import clipboard from './index.js'; | ||
|
||
(async () => { | ||
clipboard.write('你好🦄'); | ||
console.log(await clipboard.read()); | ||
})(); | ||
await clipboard.write('你好🦄'); | ||
console.log(await clipboard.read()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import execa from 'execa'; | ||
import {execa, execaSync} from 'execa'; | ||
|
||
const env = { | ||
LC_CTYPE: 'UTF-8', | ||
LC_CTYPE: 'UTF-8', // eslint-disable-line unicorn/text-encoding-identifier-case | ||
}; | ||
|
||
const clipboard = { | ||
copy: async options => execa('pbcopy', {...options, env}), | ||
paste: async options => { | ||
async paste(options) { | ||
const {stdout} = await execa('pbpaste', {...options, env}); | ||
return stdout; | ||
}, | ||
copySync: options => execa.sync('pbcopy', {...options, env}), | ||
pasteSync: options => execa.sync('pbpaste', {...options, env}).stdout, | ||
copySync: options => execaSync('pbcopy', {...options, env}), | ||
pasteSync: options => execaSync('pbpaste', {...options, env}).stdout, | ||
}; | ||
|
||
export default clipboard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
import path from 'node:path'; | ||
import {fileURLToPath} from 'node:url'; | ||
import execa from 'execa'; | ||
import arch from 'arch'; | ||
import {execa, execaSync} from 'execa'; | ||
import {is64bitSync} from 'is64bit'; | ||
|
||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
|
||
const binarySuffix = arch() === 'x64' ? 'x86_64' : 'i686'; | ||
const binarySuffix = is64bitSync() ? 'x86_64' : 'i686'; | ||
|
||
// Binaries from: https://github.com/sindresorhus/win-clipboard | ||
const windowBinaryPath = path.join(__dirname, `../fallbacks/windows/clipboard_${binarySuffix}.exe`); | ||
|
||
const clipboard = { | ||
copy: async options => execa(windowBinaryPath, ['--copy'], options), | ||
paste: async options => { | ||
async paste(options) { | ||
const {stdout} = await execa(windowBinaryPath, ['--paste'], options); | ||
return stdout; | ||
}, | ||
copySync: options => execa.sync(windowBinaryPath, ['--copy'], options), | ||
pasteSync: options => execa.sync(windowBinaryPath, ['--paste'], options).stdout, | ||
copySync: options => execaSync(windowBinaryPath, ['--copy'], options), | ||
pasteSync: options => execaSync(windowBinaryPath, ['--paste'], options).stdout, | ||
}; | ||
|
||
export default clipboard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters