0.0.2 • Published 3 months ago

@kyleupton/glob-copy v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

glob-copy

Node version

Copy utility based on Node.js streams with glob support

Features

  • Glob support
  • Progress reporting
  • Stream based
  • CJS + ESM exports

Install

yarn add @kyleupton/glob-copy

Example

import { copy } from '@kyleupton/glob-copy'

await copy({
  source: '/Users/kyleupton/Documents',
  destination: '/Volumes/Untitled',
  glob: ['**/*.bin'],
  options: {
    deep: 1
  },
  onProgress: (progress) => { console.log(progress) }
})

Remarks

Glob

In order to form the list of what files to copy, glob-copy uses, well, globs. Spicifically we use a package called fast-glob. The input glob can be either a string or an array of strings. We set the current working directory to whatever source is, so the glob should be relative to that. If the input glob is left empty, **/* is used which will grab everything.

API Reference

copy(param)

Returns: Promise<void>

param

Type: Object

source

Type: string

The source directory

destination

Type: string

Destination directory files get copied to

glob (Optional)

Type: string | string[] | undefined

Default: **/*

Glob representing which files to include

options (Optional)

Type: Object -> fast-glob.Options

Options that are passed to fast-glob

Note: This library will always pass back at least { cwd: source, stats: true }

onProgress (Optional)

Type: function(progress: t_progress) => void

t_progress:

{
  percentage: number;
  transferred: number;
  speed: number;
  eta: number;
}

The function that get's called on progress

0.0.2

3 months ago

0.0.1

7 months ago