Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marinerer/simple-copy
Simple copy-cli, copy files & directories width glob
https://github.com/marinerer/simple-copy
cli copy copyfile directory file files fs
Last synced: 7 days ago
JSON representation
Simple copy-cli, copy files & directories width glob
- Host: GitHub
- URL: https://github.com/marinerer/simple-copy
- Owner: Marinerer
- Created: 2018-12-06T04:31:29.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2018-12-20T02:32:24.000Z (almost 6 years ago)
- Last Synced: 2024-10-29T23:56:23.879Z (8 days ago)
- Topics: cli, copy, copyfile, directory, file, files, fs
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# simple-copy
> Simple copy-cli, copy files & directories width glob
## Table of Contents
- [Installation](#Installation)
- [Usage](#Usage)
- [Options](#Options)
- [CLI](#CLI)## Installation
```
npm install simple-copy --save-dev
```or
```
yarn add -D simple-copy
```## Usage
> ⚠️ Directory must end with `/`
eg. `/statics/images/`
```js
const copy = require('simple-copy')// copy(srcPath, dstPath[, options, callback])
/**
* copy one file
*/
copy('images/banner.jpg', 'statics/img/bg.jpg')/**
* copy files
*/
copy('images/*.jpg', 'statics/img/')
// overwrite
copy('images/**', 'statics/img/')
// do not overwrite
copy('images/**', 'statics/img/', { overwrite: false })/**
* copy directory
*/
copy('images/', file => `statics/${Date.now()}/${file}`)
copy('images/**', file => `statics/${file}`)```
## Options
```js
copy(srcPath, dstPath[, options, callback])
```- `src` `{String|Object|Array}` Pattern to be matched
- `dest` `{String | Function}` Destination directory
- `Options` `{Object}` flag or callback function.
- `overwrite` `{Boolean}` Overwrite existing files
- `depth` `{Boolean}` Recursive source directory
- `cb` `{Function}` Called when an error occurs, or matches are found
- `error` `{Error | null}`
- `matches` `{Array}` filenames found matching the pattern
- `currentIndex` `{Number}` The index of the current matching file## CLI
```
npm install --global simple-copy
```or
```
yarn add -g simple-copy
```### CLI Useage
```
$ scopy [...]$ scopy --help
$ scopy -v
```- `src` Pattern to be matched
- `dest` Destination directory
- `[options]`
- `-O` , `--no-overwrite` Do not overwrite the destination
- `-D` , `--no-depth` Do not recursive source directory### Example
```bash
# Clone media to statics
$ scopy src/media/ dist/statics/$ scopy imgs/avatar.png imgs/*.jpg statics/
# Copy the avatar image of the png to statics directory
$ scopy imgs/avatar/*.png statics/ -D```