Giter Club home page Giter Club logo

copy's Introduction

copy NPM version NPM monthly downloads NPM total downloads Linux Build Status Windows Build Status

Copy files or directories using globs.

Table of Contents

(TOC generated by verb using markdown-toc)

Install

Install with npm:

$ npm install --save copy

Usage

var copy = require('copy');

See the API documentation for usage details and available methods.

Examples

The main export is a function that takes:

  • src - glob pattern or file path(s)
  • dest - the destination directory
  • cb - callback function
copy('*.js', 'foo', function(err, files) {
  if (err) throw err;
  // `files` is an array of the files that were copied
});

Usage with gulp

In your project's gulpfile.js:

var gulp = require('gulp');
var copy = require('copy');

gulp.task('default', function (cb) {
  copy('fixtures/*.txt', 'actual', cb);
});

API

Copy a filepath, vinyl file, array of files, or glob of files to the given destination directory, with options and callback function that exposes err and the array of vinyl files that are created by the copy operation.

Params

  • patterns {String|Object|Array}: Filepath(s), vinyl file(s) or glob of files.
  • dir {String}: Destination directory
  • options {Object|Function}: or callback function
  • cb {Function}: Callback function if no options are specified

Example

copy('*.js', 'dist', function(err, file) {
  // exposes the vinyl `file` created when the file is copied
});

Copy an array of files to the given destination directory, with options and callback function that exposes err and the array of vinyl files that are created by the copy operation.

Params

  • files {Array}: Filepaths or vinyl files.
  • dir {String}: Destination directory
  • options {Object|Function}: or callback function
  • cb {Function}: Callback function if no options are specified

Example

copy.each(['foo.txt', 'bar.txt', 'baz.txt'], 'dist', function(err, files) {
  // exposes the vinyl `files` created when the files are copied
});

Copy a single file to the given dest directory, using the specified options and callback function.

Params

  • file {String|Object}: Filepath or vinyl file
  • dir {String}: Destination directory
  • options {Object|Function}: or callback function
  • cb {Function}: Callback function if no options are specified

Example

copy.one('foo.txt', 'dist', function(err, file) {
  if (err) throw err;
  // exposes the vinyl `file` that is created when the file is copied
});

CLI

To use the CLI, install copy globally with the following command:

$ npm install --global copy

This adds copy to your system path, allowing the copy command to be executed anywhere.

CLI usage

$ copy <patterns> <dir>
  • patterns: glob pattern or array of file paths
  • dir: destination directory

Example

Copy* all files with the .js extension to the foo directory

$ copy *.js foo

*Note that glob patterns may need to be wrapped in quotes depending on the shell you're using.

History

v0.2.0 - breaking changes

About

Related projects

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Contributors

Commits Contributor
61 jonschlinkert
2 joakimbeng
1 bleathem
1 doowb
1 gsantiago
1 SoulRIver2015

Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test

Author

Jon Schlinkert

License

Copyright © 2017, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.6.0, on September 01, 2017.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.