Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
The copyfiles npm package is a tool designed for copying files from one location to another within a file system. It is particularly useful in build processes and scripts where you need to move files around in a cross-platform compatible way. It supports features like glob patterns for file selection, creating directories as needed, and specifying the depth of directories to copy.
Basic file copying
This command copies all .txt files from 'path/to/source' to 'path/to/destination', flattening the directory structure by one level.
copyfiles -u 1 path/to/source/*.txt path/to/destination
Copying with directory structure
Copies all .html files from 'path/to/source' to 'path/to/destination', preserving the directory structure.
copyfiles path/to/source/**/*.html path/to/destination
Verbose output
Copies all .css files from 'path/to/source' to 'path/to/destination' with verbose output, showing the files as they are copied.
copyfiles -v path/to/source/*.css path/to/destination
ncp (node-copy-paste) is a Node.js package that provides asynchronous recursive file & directory copying. Compared to copyfiles, ncp offers a more programmatic API and supports copying directories recursively, but it does not support glob patterns directly.
fs-extra adds file system methods that aren't included in the native fs module and adds promise support to fs methods. It includes 'copy' and 'copySync' for copying files and directories. fs-extra is more comprehensive than copyfiles as it provides a wide range of file system operations beyond copying.
cpy is a Node.js module to copy files. It supports copying multiple files and glob patterns, similar to copyfiles. cpy provides a promise-based API, making it a good choice for use in asynchronous workflows. It's comparable to copyfiles but with a focus on promises and modern JavaScript syntax.
copy files easily
npm install copyfiles -g
Usage: copyfiles [options] inFile [more files ...] outDirectory
Options:
-u, --up slice a path off the bottom of the paths [number]
-a, --all include files & directories begining with a dot (.) [boolean]
-f, --flat flatten the output [boolean]
-e, --exclude pattern or glob to exclude (may be passed multiple times)
-E, --error throw error if nothing is copied [boolean]
-V, --verbose print more information to console [boolean]
-s, --soft do not overwrite destination files if they exist [boolean]
-F, --follow follow symbolink links [boolean]
-v, --version Show version number [boolean]
-h, --help Show help [boolean]
copy some files, give it a bunch of arguments, (which can include globs), the last one is the out directory (which it will create if necessary). Note: on windows globs must be double quoted, everybody else can quote however they please.
copyfiles foo foobar foo/bar/*.js out
you now have a directory called out, with the files foo and foobar in it, it also has a directory named foo with a directory named bar in it that has all the files from foo/bar that match the glob.
If all the files are in a folder that you don't want in the path out path, ex:
copyfiles something/*.js out
which would put all the js files in out/something
, you can use the --up
(or -u
) option
copyfiles -u 1 something/*.js out
which would put all the js files in out
you can also just do -f which will flatten all the output into one directory, so with files ./foo/a.txt and ./foo/bar/b.txt
copyfiles -f ./foo/*.txt ./foo/bar/*.txt out
will put a.txt and b.txt into out
if your terminal doesn't support globstars then you can quote them
copyfiles -f ./foo/**/*.txt out
does not work by default on a mac
but
copyfiles -f "./foo/**/*.txt" out
does.
You could quote globstars as a part of input:
copyfiles some.json "./some_folder/*.json" ./dist/ && echo 'JSON files copied.'
You can use the -e option to exclude some files from the pattern, so to exclude all all files ending in .test.js you could do
copyfiles -e "**/*.test.js" -f ./foo/**/*.js out
Other options include
-a
or --all
which includes files that start with a dot.-s
or --soft
to soft copy, which will not overwrite existing files.-F
or --follow
which follows symbolinksalso creates a copyup
command which is identical to copyfiles
but -up
defaults to 1
var copyfiles = require('copyfiles');
copyfiles([paths], opt, callback);
takes an array of paths, last one is the destination path, also takes an optional argument which the -u option if a number, otherwise if it's true
it's the flat option or if it is an object it is a hash of the various options (the long version e.g. up, all, flat, exclude, error, verbose, follow, and soft)
when the src/dest path start with tilde for home directory under windows, please make sure -u or -f is added in options or use copyup command. if not you will get Error: Illegal characters in path.
FAQs
copy some files
The npm package copyfiles receives a total of 1,093,013 weekly downloads. As such, copyfiles popularity was classified as popular.
We found that copyfiles 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.