AmathronUtilClipboardWin
is a Node.js utility module for copying file paths to the Windows clipboard asynchronously. It is especially useful in desktop and command-line applications where integrating clipboard operations is required. It uses PowerShell to interact with the clipboard as this is the most straightforward way without involving extra apps.
To install AmathronUtilClipboardWin
, use:
Pnpm:
pnpm add @amathron/copy-file-to-clipboard-win
Yarn:
yarn add @amathron/copy-file-to-clipboard-win
Npm:
npm install @amathron/copy-file-to-clipboard-win
Here's a quick example to get you started:
import AmathronUtilClipboardWin from '@amathron/copy-file-to-clipboard-win';
async function copyFiles() {
const filePaths = ['path/to/your/file1.txt', 'path/to/your/file2.txt'];
try {
await AmathronUtilClipboardWin.copyFileToClipboardAsync(filePaths);
console.log('Files have been copied to the clipboard.');
} catch (error) {
console.error('Error copying files to the clipboard:', error);
}
}
copyFiles();
- Description: Copies the contents of the specified files to the Windows clipboard.
- Parameters:
filePaths
: An array of strings, where each string is a path to a file.
- Returns: A promise that resolves to a string indicating success.
- Node.js (version 12 or higher recommended)
- Windows operating system
- PowerShell execution must be enabled. This should be the case for most developers working on windows.
Contributions to AmathronUtilClipboardWin
are welcome! Please ensure that your contributions adhere to the following guidelines:
- Write clean, readable code and maintain the existing coding style.
- Add comments to your code where necessary.
- Update the README.md with details of changes to the interface or significant changes.
This project is licensed under the MIT License.
For any inquiries or issues, please open an issue on the GitHub repository.
Initial release.