All Projects → mysticatea → Cpx

mysticatea / Cpx

Licence: mit
A cli tool to watch and copy file globs.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Cpx

Npm Run All
A CLI tool to run multiple npm-scripts in parallel or sequential.
Stars: ✭ 4,496 (+1041.12%)
Mutual labels:  cli, cli-command, npm, npm-package, npm-module
Singlespotify
🎵 Create Spotify playlists based on one artist through the command line
Stars: ✭ 254 (-35.53%)
Mutual labels:  cli, npm, npm-package, npm-module
Jsonexport
{} → 📄 it's easy to convert JSON to CSV
Stars: ✭ 208 (-47.21%)
Mutual labels:  cli, npm, npm-package, npm-module
Forge Node App
🛠📦🎉 Generate Node.js boilerplate with optional libraries & tools
Stars: ✭ 90 (-77.16%)
Mutual labels:  cli, npm-package, npm-module
Nls
Missing inspector for npm packages.
Stars: ✭ 44 (-88.83%)
Mutual labels:  cli, npm, npm-package
Github Files Fetcher
Download a specific folder or file from a GitHub repo through command line
Stars: ✭ 73 (-81.47%)
Mutual labels:  cli, npm-package, file
Eslint Plugin Vue
Official ESLint plugin for Vue.js
Stars: ✭ 3,592 (+811.68%)
Mutual labels:  npm, npm-package, npm-module
Getme
CLI utility for everyday tasks. With getme you get weather, forecast, currency rate, upload files, IP address, word definitions, text translations, internet speed, do google searches, get inspirational quotes and get Chuck Norris jokes
Stars: ✭ 118 (-70.05%)
Mutual labels:  cli, npm, npm-package
Xcv
✂️ Cut, Copy and Paste files with Bash
Stars: ✭ 144 (-63.45%)
Mutual labels:  cli, copy, glob
Fcfilemanager
iOS File Manager on top of NSFileManager for simplifying files management. 📂
Stars: ✭ 862 (+118.78%)
Mutual labels:  directory, copy, file
Npm Build Boilerplate
A collection of packages that build a website using npm scripts.
Stars: ✭ 963 (+144.42%)
Mutual labels:  cli, watch, npm
Ngx Smart Modal
Modal/Dialog component crafted for Angular
Stars: ✭ 256 (-35.03%)
Mutual labels:  npm, npm-package, npm-module
Yarpm
CLI tool to run npm scripts with either npm or yarn, depending on how it was started
Stars: ✭ 13 (-96.7%)
Mutual labels:  cli, npm, npm-package
Redrun
✨🐌 🐎✨ fastest npm scripts runner
Stars: ✭ 85 (-78.43%)
Mutual labels:  cli, cli-command, npm
Np
A better `npm publish`
Stars: ✭ 6,401 (+1524.62%)
Mutual labels:  cli, npm, npm-package
Ohshitgit
⁉️Oh shit! A cli tool to help you unfuck your git mistakes
Stars: ✭ 135 (-65.74%)
Mutual labels:  cli, npm, npm-package
Rollup Plugin Copy
Copy files and folders using Rollup
Stars: ✭ 128 (-67.51%)
Mutual labels:  copy, glob, file
Copy Webpack Plugin
Copy files and directories with webpack
Stars: ✭ 2,679 (+579.95%)
Mutual labels:  copy, glob, file
Cash Cli
💰💰 Convert currency rates directly from your terminal!
Stars: ✭ 168 (-57.36%)
Mutual labels:  cli, npm, npm-package
Tree Node Cli
🌲 Node.js library to list the contents of directories in a tree-like format, similar to the Linux tree command
Stars: ✭ 102 (-74.11%)
Mutual labels:  directory, cli, file

cpx

npm version Downloads/month Build Status codecov Dependency Status

Copy file globs, watching for changes.

This module provides a CLI tool like cp, but with watching.

Installation

npm install cpx
  • Requires Node.js >=6.5.

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.

var cpx = require("cpx");

cpx.copy

cpx.copy(source, dest, options, callback)
cpx.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 for cpx.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 a stream.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.
  • callback {(err: Error|null) => void} -- A function that is called at done.

Copy files that matches with source glob to dest directory.

cpx.copySync

cpx.copySync(source, dest, options)
cpx.copySync(source, dest)

A synchronous function of cpx.copy.

Arguments is almost same as cpx.copy. But options.transform is not supported.

cpx.watch

cpx.watch(source, dest, options)
cpx.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-ready", () => { ... }) : Be fired when started watching files, after the first copying.
  • .on("watch-error", (err) => { ... }) : Be fired when occured errors during watching.

Changelog

GitHub Releases

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 last npm test command with web browser.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].