0.2.0 • Published 7 years ago

lazycopy v0.2.0

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

lazycopy

This is a utility package that does only one thing: copy files in glob patterns to destination and retain the relative directory structure.

It's called lazycopy because I never want to write another set of functions to copy files, and I don't want to use gulp or grunt (or any other task runner) for automating my front-end builds :)

Installation

npm install lazycopy

Usage

const lazy = require('lazycopy').default; // If you're not using ES6 Modules


import lazy from 'lazycopy'; // If you're using ES6 modules

API

copy(sources)

Copies an array of sources to their destination, but does so asynchronously. Returns a Promise that will be resolved when the copy operations have completed. Rejects promise if an error occurs while copying.

If the required folders do no exist in the destination path, they will be automatically created.

Arguments

sources - An Array of objects containing the following properties:

  • src - required - Glob pattern for file selection
  • dest - required - Output folder where files will be copied to
  • cwd - optional - Root where lazycopy will look for files to copy
  • maintainStructure - optional (defaults to true) - If set to false, the file's relative structure will not be preserved

Example:

// Copy files async (Promise-based)
lazy.copy([{
    src: './someFolder/**/**', // Give me all the files under "someFolder"
    dest: './destination',
    cwd: __dirname // (Optionally set CWD for scanning for files)
}]).then(() => {
    console.info('Done!');
}).catch((error) => {
    console.info('Something blew up.');
    console.error(error);
});

copySync(sources) Performs a synchronous copy of files.

Example:

// Copy files synchronously
lazy.copySync([{
    src: './someFolder/**/**', // Give me all the files under "someFolder"
    dest: './destination',
    cwd: __dirname // (Optionally set CWD for scanning for files)
}]);
0.2.0

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago