Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bumped packages, using --up #33

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 15 additions & 8 deletions cli.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#!/usr/bin/env node
'use strict';
const meow = require('meow');
const cpy = require('cpy');
import meow from 'meow';
import cpy from 'cpy';

const cli = meow(`
Usage
$ cpy <source …> <destination>

Options
--no-overwrite Don't overwrite the destination
--parents Preserve path structure
--no-flat Preserve path structure
--cwd=<dir> Working directory for files
--rename=<filename> Rename all <source> filenames to <filename>
--dot Allow patterns to match entries that begin with a period (.)
--up Trim path from files being copied

<source> can contain globs if quoted

Expand All @@ -21,16 +22,17 @@ const cli = meow(`
$ cpy 'src/*.png' '!src/goat.png' dist

Copy all .html files inside src folder into dist and preserve path structure
$ cpy '**/*.html' '../dist/' --cwd=src --parents
$ cpy '**/*.html' '../dist/' --cwd=src --no-flat
`, {
importMeta: import.meta,
flags: {
overwrite: {
type: 'boolean',
default: true
},
parents: {
flat: {
type: 'boolean',
default: false
default: true
},
cwd: {
type: 'string',
Expand All @@ -42,6 +44,10 @@ const cli = meow(`
dot: {
type: 'boolean',
default: false
},
up: {
type: 'number',
default: 0
}
}
});
Expand All @@ -51,9 +57,10 @@ const cli = meow(`
await cpy(cli.input, cli.input.pop(), {
cwd: cli.flags.cwd,
rename: cli.flags.rename,
parents: cli.flags.parents,
flat: cli.flags.flat,
overwrite: cli.flags.overwrite,
dot: cli.flags.dot
dot: cli.flags.dot,
up: cli.flags.up
});
} catch (error) {
if (error.name === 'CpyError') {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "cpy-cli",
"version": "3.1.1",
"type": "module",
"description": "Copy files",
"license": "MIT",
"repository": "sindresorhus/cpy-cli",
Expand Down Expand Up @@ -51,7 +52,7 @@
],
"dependencies": {
"cpy": "^8.0.0",
"meow": "^6.1.1"
"meow": "^10.1.1"
},
"devDependencies": {
"ava": "^2.4.0",
Expand Down
5 changes: 3 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ $ cpy --help

Options
--no-overwrite Don't overwrite the destination
--parents Preserve path structure
--no-flat Preserve path structure
--cwd=<dir> Working directory for files
--rename=<filename> Rename all <source> filenames to <filename>
--dot Allow patterns to match entries that begin with a period (.)
--up Trim path from files being copied

<source> can contain globs if quoted

Expand All @@ -37,7 +38,7 @@ $ cpy --help
$ cpy 'src/*.png' '!src/goat.png' dist

Copy all .html files inside src folder into dist and preserve path structure
$ cpy '**/*.html' '../dist/' --cwd=src --parents
$ cpy '**/*.html' '../dist/' --cwd=src --no-flat
```

## Related
Expand Down
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ test('cwd', async t => {
t.is(read(t.context.tmp, 'cwd/hello.js'), read(t.context.tmp, 'cwd/dest/hello.js'));
});

test('keep path structure with flag `--parents`', async t => {
test('keep path structure with flag `--no-flat`', async t => {
fs.mkdirSync(t.context.tmp);
fs.mkdirSync(path.join(t.context.tmp, 'cwd'));
fs.writeFileSync(path.join(t.context.tmp, 'cwd/hello.js'), 'console.log("hello");');

await execa('./cli.js', [path.join(t.context.tmp, 'cwd/hello.js'), t.context.tmp, '--parents']);
await execa('./cli.js', [path.join(t.context.tmp, 'cwd/hello.js'), t.context.tmp, '--no-flat']);

t.is(read(t.context.tmp, 'cwd/hello.js'), read(t.context.tmp, t.context.tmp, 'cwd/hello.js'));
});
Expand Down