|
8 | 8 | [](https://www.npmjs.com/package/native-copyfiles) |
9 | 9 | [](https://bundlejs.com/?q=native-copyfiles) |
10 | 10 |
|
11 | | -## native-copyfiles |
| 11 | +## Native-Copyfiles |
12 | 12 |
|
13 | 13 | Copy files easily via JavaScript or the CLI and cross-platform usage using [cli-nano](https://www.npmjs.com/package/cli-nano) dependency for the CLI. |
14 | 14 |
|
15 | | -The library is very similar to the [copyfiles](https://www.npmjs.com/package/copyfiles) package, at least from the outside; however it is quite different internally. It uses native NodeJS as much as possible and so as a lot less dependencies (just 2 instead of 7), which makes this package a lot smaller compared to the original `copyfiles` project (1.8kB instead of 27.6kB gzip). The options are nearly the same (except for `--soft`, which is not implemented), there's also some new options that were added in this project (mainly the rename and dry-run features, see below). |
| 15 | +The library is very similar to the [copyfiles](https://www.npmjs.com/package/copyfiles) package, at least from the outside; however it is quite different internally. It uses native NodeJS as much as possible and so as a lot less dependencies (just 2 instead of 7), which makes this package a lot smaller compared to the original `copyfiles` project (1.8kB instead of 27.6kB gzip). The options are nearly the same (except for `--soft`, which is not implemented), there's also some new features that were added in this project (mainly the copy & rename and also dry-run features, see below). |
16 | 16 |
|
17 | | -> **Note**: there is 1 noticeable difference with `copyfiles` package, all the CLI options must be provided as suffix and after the source/target directories command (the original `copyfiles` project has them as prefix).<br> |
| 17 | +> [!NOTE] |
| 18 | +> There is 1 noticeable difference with `copyfiles` package, all the CLI options must be provided as suffix and after the source/target directories command (the original `copyfiles` project has them as prefix).<br> |
18 | 19 | > This mean calling: `copyfiles source target [options]` instead of `copyfiles [options] source target` |
19 | 20 | > The JS API is also different since the destination is the 2nd function argument instead of the first argument. |
20 | 21 |
|
21 | | -> [!NOTE] |
22 | | -> This project now requires Node.JS >= 22.17.0 so that we can use the native `fs.glob` and decrease the projet size. If you can't update your Node.JS just yet, then just stick with `native-copyfiles: ^1.3.7` until you can. The version 2.0 bumped Node requirement and changed the JS API arguments (see below). |
23 | | -
|
24 | | -### Advanced Glob Pattern Support |
| 22 | +### Major Changes |
| 23 | +#### version 1.0 |
| 24 | +- similar to [copyfiles](https://www.npmjs.com/package/copyfiles) package except that options are suffixes instead of prefixes |
25 | 25 |
|
26 | | -`native-copyfiles` supports advanced glob patterns, including: |
| 26 | +#### version 1.0 to 2.0 |
| 27 | +- see [Migration](https://github.com/ghiscoding/native-copyfiles/releases/tag/v2.0.0) details |
| 28 | +- drop `tinyglobby` and use `fs.glob` native code (requires Node.JS >=22.17) |
| 29 | +- change JS API arguments (sources and destination are now 2 separate arguments) |
27 | 30 |
|
28 | | -- **Brace expansion**: e.g. `src/*.{js,ts}` |
29 | | -- **Negation**: e.g. `['src/**/*.js', '!src/**/*.test.js']` |
30 | | -- **Extended wildcards**: e.g. `**/*.js`, `*bar?.js` |
31 | | -- **Dotfiles**: Use `-a`/`--all` to include files starting with a dot |
32 | | - |
33 | | -This makes it easier to match complex sets of files for copying, similar to Bash or advanced glob libraries. |
| 31 | +--- |
34 | 32 |
|
35 | 33 | ### Install |
36 | 34 |
|
@@ -73,8 +71,18 @@ copyfiles foo foobar foo/bar/*.js out |
73 | 71 | you now have a directory called `"out"`, with the files `"foo"` and `"foobar"` in it, it also has a directory named `"foo"` with a directory named |
74 | 72 | `"bar"` in it that has all the files from `"foo/bar"` that match the glob. |
75 | 73 |
|
| 74 | +### Advanced Glob Pattern Support |
| 75 | + |
| 76 | +`native-copyfiles` supports advanced glob patterns, including: |
| 77 | + |
| 78 | +- **Brace expansion**: e.g. `src/*.{js,ts}` |
| 79 | +- **Negation**: e.g. `['src/**/*.js', '!src/**/*.test.js']` |
| 80 | +- **Extended wildcards**: e.g. `**/*.js`, `*bar?.js` |
| 81 | +- **Dotfiles**: Use `-a`/`--all` to include files starting with a dot |
| 82 | + |
| 83 | +This makes it easier to match complex sets of files for copying, similar to Bash or advanced glob libraries. |
76 | 84 |
|
77 | | -#### Examples of advanced glob usage |
| 85 | +### Examples of advanced glob usage |
78 | 86 |
|
79 | 87 | **Brace expansion:** |
80 | 88 | ```bash |
@@ -137,7 +145,7 @@ copyfiles "**/*.test.js" -f "./foo/**/*.js" out -e |
137 | 145 | ``` |
138 | 146 |
|
139 | 147 | > [!NOTE] |
140 | | -> By default the `.git/` and `node_modules/` directories will be excluded (when using globs). If you provide your own `--exclude` option, it will override the defaults and only use your patterns. |
| 148 | +> By default the `.git/` and `node_modules/` directories will be excluded (when using globs). Unless you provide your own `--exclude` option, which will override the defaults and only use your patterns. |
141 | 149 |
|
142 | 150 | Other options include |
143 | 151 |
|
@@ -178,8 +186,7 @@ This will copy: |
178 | 186 | - `input/foo.css` → `output/foo.scss` |
179 | 187 | - `input/bar/baz.css` → `output/bar/baz.scss` |
180 | 188 |
|
181 | | -The `*` in the destination is replaced with the base filename from the source. |
182 | | -You can combine this with `--flat` or `--up` to control the output structure. |
| 189 | +The `*` in the destination is replaced with the source base filename. You can combine this with `--flat` or `--up` to control the output structure. |
183 | 190 |
|
184 | 191 | #### 2. Rename Using a Callback (JavaScript API) |
185 | 192 |
|
|
0 commit comments