Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
The cpy-cli npm package is a command-line interface for the cpy module, which is used to copy files and directories with various options. It is designed to be simple and efficient, making it easy to copy files from one location to another with additional features like glob patterns, renaming, and more.
Basic File Copy
This command copies the file 'source.txt' to the 'destination' directory.
cpy 'source.txt' 'destination/'
Copy Multiple Files
This command copies all .txt files from the 'src' directory to the 'dist' directory using glob patterns.
cpy 'src/*.txt' 'dist/'
Rename Files While Copying
This command copies 'source.txt' to the 'destination' directory and renames it to 'renamed.txt'.
cpy 'source.txt' 'destination/renamed.txt'
Copy Files Recursively
This command copies all files and directories from 'src' to 'dist' recursively.
cpy 'src/**/*' 'dist/'
Preserve Timestamps
This command copies 'source.txt' to the 'destination' directory and preserves the original file timestamps.
cpy 'source.txt' 'destination/' --preserve-timestamps
The ncp (Node Copy) package is another tool for copying files and directories in Node.js. It offers similar functionality to cpy-cli but is more focused on being a programmatic API rather than a CLI tool. It supports recursive copying and can handle large directories efficiently.
The fs-extra package extends the native Node.js fs module with additional methods, including file and directory copying. It provides a more extensive API for file system operations and is widely used for its simplicity and reliability. Unlike cpy-cli, fs-extra is primarily used as a library within Node.js scripts.
ShellJS is a portable (Windows/Linux/macOS) implementation of Unix shell commands on top of the Node.js API. It provides a wide range of shell commands, including file copying. ShellJS is more versatile than cpy-cli as it supports a broader range of shell operations, but it may be overkill if you only need to copy files.
Copy files
npm install --global cpy-cli
$ cpy --help
Usage
$ cpy <source …> <destination>
Options
--no-overwrite Don't overwrite the destination
--cwd=<dir> Working directory for files
--rename=<filename> Rename all <source> filenames to <filename>. Supports string templates.
--dot Allow patterns to match entries that begin with a period (.)
--flat Flatten directory structure. All copied files will be put in the same directory.
--concurrency Number of files being copied concurrently
<source> can contain globs if quoted
Examples
Copy all .png files in src folder into dist except src/goat.png
$ cpy 'src/*.png' '!src/goat.png' dist
Copy all files inside src folder into dist and preserve path structure
$ cpy . '../dist/' --cwd=src
Copy all .png files in the src folder to dist and prefix the image filenames
$ cpy 'src/*.png' dist --cwd=src --rename=hi-{{basename}}
FAQs
Copy files
The npm package cpy-cli receives a total of 179,034 weekly downloads. As such, cpy-cli popularity was classified as popular.
We found that cpy-cli demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.