copymitter 9.0.0 → 10.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog +23 -0
- package/README.md +11 -10
- package/lib/copymitter.js +36 -28
- package/package.json +16 -16
package/ChangeLog
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
2026.02.15, v10.0.1
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- fb4a5ad copymitter: named export
|
|
5
|
+
|
|
6
|
+
2026.02.15, v10.0.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 917d280 copymitter: drop support of node < 22
|
|
10
|
+
- 12580c8 copymitter: migrate to ESM
|
|
11
|
+
- e7c1605 copymitter: try-to-catch v4.0.5
|
|
12
|
+
- c80e569 copymitter: try-catch v4.0.9
|
|
13
|
+
- 7056c21 copymitter: supertape v12.5.0
|
|
14
|
+
- d19809e copymitter: rimraf v6.1.2
|
|
15
|
+
- fbdf40e copymitter: redzip v4.0.1
|
|
16
|
+
- 3c73055 copymitter: redlint v5.7.0
|
|
17
|
+
- ca84333 copymitter: putout v41.25.1
|
|
18
|
+
- 1dfb25a copymitter: madrun v12.1.3
|
|
19
|
+
- 3736a0b copymitter: fullstore v4.0.0
|
|
20
|
+
- 247bf1e copymitter: eslint-plugin-putout v30.0.5
|
|
21
|
+
- 8cd34c8 copymitter: eslint v10.0.0
|
|
22
|
+
- 5247e65 copymitter: c8 v10.1.3
|
|
23
|
+
|
|
1
24
|
2024.05.06, v9.0.0
|
|
2
25
|
|
|
3
26
|
feature:
|
package/README.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Copymitter [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
|
|
2
2
|
|
|
3
|
+
[NPMIMGURL]: https://img.shields.io/npm/v/copymitter.svg?style=flat
|
|
4
|
+
[BuildStatusURL]: https://github.com/coderaiser/node-copymitter/actions?query=workflow%3A%22Node+CI%22 "Build Status"
|
|
5
|
+
[BuildStatusIMGURL]: https://github.com/coderaiser/node-copymitter/workflows/Node%20CI/badge.svg
|
|
6
|
+
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
|
|
7
|
+
[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/node-copymitter/badge.svg?branch=master&service=github
|
|
8
|
+
[NPMURL]: https://npmjs.org/package/copymitter "npm"
|
|
9
|
+
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
|
|
10
|
+
[CoverageURL]: https://coveralls.io/github/coderaiser/node-copymitter?branch=master
|
|
11
|
+
|
|
3
12
|
Copy files with emitter (even from and to `zip archives`). It will emit event on every percent of copied chunk of data.
|
|
4
13
|
Good for making progress bars.
|
|
5
14
|
|
|
@@ -12,7 +21,8 @@ npm i copymitter
|
|
|
12
21
|
### How to use?
|
|
13
22
|
|
|
14
23
|
```js
|
|
15
|
-
|
|
24
|
+
import {copymitter} from 'copymitter';
|
|
25
|
+
|
|
16
26
|
const cwd = process.cwd();
|
|
17
27
|
const from = `${cwd}/pipe-io`;
|
|
18
28
|
const to = `${cwd}/example`;
|
|
@@ -72,12 +82,3 @@ cp.pause();
|
|
|
72
82
|
## License
|
|
73
83
|
|
|
74
84
|
MIT
|
|
75
|
-
|
|
76
|
-
[NPMIMGURL]: https://img.shields.io/npm/v/copymitter.svg?style=flat
|
|
77
|
-
[BuildStatusURL]: https://github.com/coderaiser/node-copymitter/actions?query=workflow%3A%22Node+CI%22 "Build Status"
|
|
78
|
-
[BuildStatusIMGURL]: https://github.com/coderaiser/node-copymitter/workflows/Node%20CI/badge.svg
|
|
79
|
-
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
|
|
80
|
-
[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/node-copymitter/badge.svg?branch=master&service=github
|
|
81
|
-
[NPMURL]: https://npmjs.org/package/copymitter "npm"
|
|
82
|
-
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
|
|
83
|
-
[CoverageURL]: https://coveralls.io/github/coderaiser/node-copymitter?branch=master
|
package/lib/copymitter.js
CHANGED
|
@@ -1,45 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const squad = require('squad');
|
|
14
|
-
const tryToCatch = require('try-to-catch');
|
|
15
|
-
const copySymlink = require('copy-symlink');
|
|
16
|
-
|
|
17
|
-
const {
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {readlink} from 'node:fs/promises';
|
|
4
|
+
import {inherits} from 'node:util';
|
|
5
|
+
import {EventEmitter} from 'node:events';
|
|
6
|
+
import debug from 'debug';
|
|
7
|
+
import through2 from 'through2';
|
|
8
|
+
import currify from 'currify';
|
|
9
|
+
import squad from 'squad';
|
|
10
|
+
import {tryToCatch} from 'try-to-catch';
|
|
11
|
+
import copySymlink from 'copy-symlink';
|
|
12
|
+
import {
|
|
18
13
|
read,
|
|
19
14
|
readStat,
|
|
20
|
-
write,
|
|
15
|
+
write as _write,
|
|
21
16
|
list,
|
|
22
|
-
}
|
|
17
|
+
} from 'redzip';
|
|
18
|
+
|
|
19
|
+
const log = debug('copymitter');
|
|
23
20
|
|
|
24
21
|
const isString = (a) => typeof a === 'string';
|
|
25
22
|
|
|
26
23
|
inherits(Copymitter, EventEmitter);
|
|
27
24
|
|
|
28
|
-
|
|
25
|
+
export const copymitter = (from, to, files, overrides) => {
|
|
29
26
|
check(from, to, files);
|
|
30
27
|
|
|
31
|
-
return Copymitter(from, to, files);
|
|
28
|
+
return Copymitter(from, to, files, overrides);
|
|
32
29
|
};
|
|
33
30
|
|
|
34
31
|
const removeStr = currify((a, b) => b.replace(a, ''));
|
|
35
32
|
const pushValue = currify((array, value) => array.push(value));
|
|
36
33
|
|
|
37
|
-
function Copymitter(from, to, files) {
|
|
34
|
+
function Copymitter(from, to, files, overrides = {}) {
|
|
38
35
|
if (!(this instanceof Copymitter))
|
|
39
|
-
return new Copymitter(from, to, files);
|
|
36
|
+
return new Copymitter(from, to, files, overrides);
|
|
40
37
|
|
|
41
38
|
EventEmitter.call(this);
|
|
42
39
|
|
|
40
|
+
const {write = _write} = overrides;
|
|
41
|
+
|
|
42
|
+
this._write = write;
|
|
43
|
+
|
|
43
44
|
this._files = [];
|
|
44
45
|
this._errors = [];
|
|
45
46
|
this._size = 0;
|
|
@@ -125,7 +126,8 @@ Copymitter.prototype._cpAll = function() {
|
|
|
125
126
|
});
|
|
126
127
|
};
|
|
127
128
|
|
|
128
|
-
const copyDir = async (from, to) => {
|
|
129
|
+
const copyDir = async (from, to, overrides = {}) => {
|
|
130
|
+
const {write} = overrides;
|
|
129
131
|
const {mode} = await readStat(from);
|
|
130
132
|
|
|
131
133
|
await write(to, null, {
|
|
@@ -189,16 +191,19 @@ Copymitter.prototype.cpOneFile = function(from, to) {
|
|
|
189
191
|
emitFile,
|
|
190
192
|
emitDirectory,
|
|
191
193
|
countStream,
|
|
194
|
+
write: this._write,
|
|
192
195
|
});
|
|
193
196
|
|
|
194
197
|
return emitter;
|
|
195
198
|
};
|
|
196
199
|
|
|
197
|
-
async function copy(from, to, {emitError, emitFile, emitDirectory, countStream}) {
|
|
200
|
+
async function copy(from, to, {emitError, emitFile, emitDirectory, countStream, write}) {
|
|
198
201
|
const info = await readStat(from);
|
|
199
202
|
|
|
200
203
|
if (info.isDirectory()) {
|
|
201
|
-
const [copyDirError] = await tryToCatch(copyDir, from, to
|
|
204
|
+
const [copyDirError] = await tryToCatch(copyDir, from, to, {
|
|
205
|
+
write,
|
|
206
|
+
});
|
|
202
207
|
|
|
203
208
|
if (copyDirError)
|
|
204
209
|
return emitError(copyDirError);
|
|
@@ -206,7 +211,9 @@ async function copy(from, to, {emitError, emitFile, emitDirectory, countStream})
|
|
|
206
211
|
return emitDirectory();
|
|
207
212
|
}
|
|
208
213
|
|
|
209
|
-
const [error] = await tryToCatch(superCopy, from, to, [countStream]
|
|
214
|
+
const [error] = await tryToCatch(superCopy, from, to, [countStream], {
|
|
215
|
+
write,
|
|
216
|
+
});
|
|
210
217
|
|
|
211
218
|
if (error)
|
|
212
219
|
return emitError(error);
|
|
@@ -214,7 +221,8 @@ async function copy(from, to, {emitError, emitFile, emitDirectory, countStream})
|
|
|
214
221
|
emitFile();
|
|
215
222
|
}
|
|
216
223
|
|
|
217
|
-
async function superCopy(from, to, [countStream]) {
|
|
224
|
+
async function superCopy(from, to, [countStream], overrides) {
|
|
225
|
+
const {write} = overrides;
|
|
218
226
|
const [, link] = await tryToCatch(readlink, from);
|
|
219
227
|
|
|
220
228
|
if (link) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "copymitter",
|
|
3
|
-
"version": "
|
|
4
|
-
"type": "
|
|
3
|
+
"version": "10.0.1",
|
|
4
|
+
"type": "module",
|
|
5
5
|
"description": "copy files with emitter",
|
|
6
6
|
"main": "lib/copymitter.js",
|
|
7
7
|
"scripts": {
|
|
@@ -19,33 +19,33 @@
|
|
|
19
19
|
"currify": "^4.0.0",
|
|
20
20
|
"debug": "^4.0.1",
|
|
21
21
|
"findit2": "^2.2.3",
|
|
22
|
-
"fullstore": "^
|
|
22
|
+
"fullstore": "^4.0.0",
|
|
23
23
|
"mkdirp": "^3.0.1",
|
|
24
|
-
"redzip": "^
|
|
24
|
+
"redzip": "^4.0.1",
|
|
25
25
|
"squad": "^3.0.0",
|
|
26
26
|
"through2": "^4.0.2",
|
|
27
|
-
"try-to-catch": "^
|
|
27
|
+
"try-to-catch": "^4.0.5",
|
|
28
28
|
"zames": "^3.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@iocmd/wait": "^2.1.0",
|
|
32
|
-
"c8": "^
|
|
33
|
-
"eslint": "^
|
|
32
|
+
"c8": "^10.1.3",
|
|
33
|
+
"eslint": "^10.0.0",
|
|
34
34
|
"eslint-plugin-node": "^11.0.0",
|
|
35
|
-
"eslint-plugin-putout": "^
|
|
36
|
-
"madrun": "^
|
|
35
|
+
"eslint-plugin-putout": "^30.0.5",
|
|
36
|
+
"madrun": "^12.1.3",
|
|
37
37
|
"mock-require": "^3.0.3",
|
|
38
38
|
"nodemon": "^3.1.0",
|
|
39
39
|
"pullout": "^5.0.1",
|
|
40
|
-
"putout": "^
|
|
41
|
-
"redlint": "^
|
|
42
|
-
"rimraf": "^
|
|
43
|
-
"supertape": "^
|
|
44
|
-
"try-catch": "^
|
|
40
|
+
"putout": "^41.25.1",
|
|
41
|
+
"redlint": "^5.7.0",
|
|
42
|
+
"rimraf": "^6.1.2",
|
|
43
|
+
"supertape": "^12.5.0",
|
|
44
|
+
"try-catch": "^4.0.9"
|
|
45
45
|
},
|
|
46
46
|
"repository": {
|
|
47
47
|
"type": "git",
|
|
48
|
-
"url": "git://github.com/coderaiser/node-copymitter.git"
|
|
48
|
+
"url": "git+https://github.com/coderaiser/node-copymitter.git"
|
|
49
49
|
},
|
|
50
50
|
"keywords": [
|
|
51
51
|
"copy",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"file"
|
|
56
56
|
],
|
|
57
57
|
"engines": {
|
|
58
|
-
"node": ">=
|
|
58
|
+
"node": ">=22"
|
|
59
59
|
},
|
|
60
60
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (http://coderaiser.github.io/)",
|
|
61
61
|
"license": "MIT",
|