Installations
npm install cpx
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
6.3.0
NPM Version
3.8.9
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
mysticatea
Download Statistics
Total Downloads
94,212,607
Last Day
2,779
Last Week
2,779
Last Month
757,373
Last Year
13,950,070
GitHub Statistics
527 Stars
96 Commits
36 Forks
6 Watching
1 Branches
7 Contributors
Bundle Size
299.19 kB
Minified
87.35 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.5.0
Package Id
cpx@1.5.0
Size
11.48 kB
NPM Version
3.8.9
Node Version
6.3.0
Publised On
04 Sept 2016
Total Downloads
Cumulative downloads
Total Downloads
94,212,607
Last day
0%
2,779
Compared to previous day
Last week
-98.3%
2,779
Compared to previous week
Last month
-9.3%
757,373
Compared to previous month
Last year
-1.2%
13,950,070
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
11
cpx
Copy file globs, watching for changes.
This module provides a CLI tool like cp
, but with watching.
Installation
npm install cpx
Usage
Usage: cpx <source> <dest> [options]
Copy files, watching for changes.
<source> The glob of target files.
<dest> The path of a destination directory.
Options:
-c, --command <command> A command text to transform each file.
-C, --clean Clean files that matches <source> like pattern in
<dest> directory before the first copying.
-L, --dereference Follow symbolic links when copying from them.
-h, --help Print usage information.
--include-empty-dirs The flag to copy empty directories which is
matched with the glob.
--no-initial The flag to not copy at the initial time of watch.
Use together '--watch' option.
-p, --preserve The flag to copy attributes of files.
This attributes are uid, gid, atime, and mtime.
-t, --transform <name> A module name to transform each file. cpx lookups
the specified name via "require()".
-u, --update The flag to not overwrite files on destination if
the source file is older.
-v, --verbose Print copied/removed files.
-V, --version Print the version number.
-w, --watch Watch for files that matches <source>, and copy
the file to <dest> every changing.
Example
$ cpx "src/**/*.{html,png,jpg}" app --watch
This example will copy html/png/jpg files from src
directory to app
directory, keeping file tree structure.
Whenever the files are changed, copy them.
Since Bash expands globs, requires to enclose it with double quotes.
You can use together Browserify.
$ cpx "src/**/*.{html,png,jpg}" app -w & watchify src/index.js -o app/index.js
You can use shell commands to convert each file.
$ cpx "src/**/*.js" app -w -c "babel --source-maps inline"
You can use the transform packages for Browserify.
$ cpx "src/**/*.js" app -w -t babelify -t uglifyify
It maybe can use to add header comment, to optimize images, or etc...
Node.js API
You can use this module as a node module.
1var cpx = require("cpx");
cpx.copy
1cpx.copy(source, dest, options, callback) 2cpx.copy(source, dest, callback)
- source
{string}
-- A file glob of copy targets. - dest
{string}
-- A file path of a destination directory. - options
{object}
- options.clean
{boolean}
-- The flag to remove files that copied on past before copy. Default:false
. - options.dereference
{boolean}
-- The flag to follow symbolic links when copying from them. Default:false
. - options.includeEmptyDirs
{boolean}
-- The flag to copy empty directories which is matched with the glob. Default:false
. - options.initialCopy
{boolean}
-- The flag to not copy at the initial time of watch. This is forcpx.watch()
. Default:true
. - options.preserve
{boolean}
-- The flag to copy uid, gid, atime, and mtime of files. Default:false
. - options.transform
{((filepath: string) => stream.Transform)[]}
-- Functions that creates astream.Transform
object to transform each copying file. - options.update
{boolean}
-- The flag to not overwrite files on destination if the source file is older. Default:false
.
- options.clean
- callback
{(err: Error|null) => void}
-- A function that is called at done.
Copy files that matches with source
glob to dest
directory.
cpx.copySync
1cpx.copySync(source, dest, options)
2cpx.copySync(source, dest)
A synchronous function of cpx.copy
.
Arguments is almost same as cpx.copy
.
But options.transform
is not supported.
cpx.watch
1cpx.watch(source, dest, options) 2cpx.watch(source, dest)
Copy files that matches with source
glob string to dest
directory.
After the first copy, starts observing. And copy the files when every changes.
Arguments is same as cpx.copy
.
cpx.watch
returns an EventEmitter
.
.on("copy", (e) => { ... })
: Be fired after file is copied.e.srcPath
is a path of original file.e.dstPath
is a path of new file..on("remove", (e) => { ... })
: Be fired after file is removed.e.path
is a path of removed file..on("watch-raedy", () => { ... })
: Be fired when started watching files, after the first copying..on("watch-error", (err) => { ... })
: Be fired when occured errors during watching.
Changelog
Contributing
Thank you for contributions!
Bug Reports or Feature Requests
Please use GitHub Issues.
Document Corrections
Please use GitHub Pull Requests. I would especially thank for document corrections since I'm not familiar with English.
Feature Implementing
Please use GitHub Pull Requests.
There are some npm-scripts to help developments.
npm test
- Run tests and collect coverage.npm run build
- Make lib directory from src directory.npm run clean
- Delete directories (folders) which are created by other commands.npm run lint
- Run ESLint.npm run watch
- Run tests (not collect coverage) when each file was modified.npm run open-coverage
- Open the coverage report of the lastnpm test
command with web browser.
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 existing vulnerabilities detected
Reason
Found 4/28 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 6 are checked with a SAST tool
Score
3.2
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More