copymitter 8.1.0 → 10.0.0
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 +33 -0
- package/README.md +11 -10
- package/lib/copymitter.js +38 -28
- package/package.json +19 -18
package/ChangeLog
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
2026.02.15, v10.0.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 917d280 copymitter: drop support of node < 22
|
|
5
|
+
- 12580c8 copymitter: migrate to ESM
|
|
6
|
+
- e7c1605 copymitter: try-to-catch v4.0.5
|
|
7
|
+
- c80e569 copymitter: try-catch v4.0.9
|
|
8
|
+
- 7056c21 copymitter: supertape v12.5.0
|
|
9
|
+
- d19809e copymitter: rimraf v6.1.2
|
|
10
|
+
- fbdf40e copymitter: redzip v4.0.1
|
|
11
|
+
- 3c73055 copymitter: redlint v5.7.0
|
|
12
|
+
- ca84333 copymitter: putout v41.25.1
|
|
13
|
+
- 1dfb25a copymitter: madrun v12.1.3
|
|
14
|
+
- 3736a0b copymitter: fullstore v4.0.0
|
|
15
|
+
- 247bf1e copymitter: eslint-plugin-putout v30.0.5
|
|
16
|
+
- 8cd34c8 copymitter: eslint v10.0.0
|
|
17
|
+
- 5247e65 copymitter: c8 v10.1.3
|
|
18
|
+
|
|
19
|
+
2024.05.06, v9.0.0
|
|
20
|
+
|
|
21
|
+
feature:
|
|
22
|
+
- c2a6aad package: drop support of node < 18
|
|
23
|
+
- a437d76 copymitter: redlint v3.14.1
|
|
24
|
+
- 52a9479 copymitter: eslint v9.2.0
|
|
25
|
+
- 96f7c54 copymitter: eslint-plugin-putout v22.6.1
|
|
26
|
+
- a3712c8 copymitter: madrun v10.0.1
|
|
27
|
+
- b809b30 copymitter: supertape v10.5.0
|
|
28
|
+
- 35f664b copymitter: putout v35.20.0
|
|
29
|
+
- 92930be copymitter: nodemon v3.1.0
|
|
30
|
+
- 3d9f16a copymitter: mkdirp v3.0.1
|
|
31
|
+
- 0b37a74 copymitter: c8 v9.1.0
|
|
32
|
+
- d4455bc copymitter: pullout v5.0.1
|
|
33
|
+
|
|
1
34
|
2023.08.09, v8.1.0
|
|
2
35
|
|
|
3
36
|
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,43 +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');
|
|
20
|
+
|
|
21
|
+
const isString = (a) => typeof a === 'string';
|
|
23
22
|
|
|
24
23
|
inherits(Copymitter, EventEmitter);
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
export default (from, to, files, overrides) => {
|
|
27
26
|
check(from, to, files);
|
|
28
27
|
|
|
29
|
-
return Copymitter(from, to, files);
|
|
28
|
+
return Copymitter(from, to, files, overrides);
|
|
30
29
|
};
|
|
31
30
|
|
|
32
31
|
const removeStr = currify((a, b) => b.replace(a, ''));
|
|
33
32
|
const pushValue = currify((array, value) => array.push(value));
|
|
34
33
|
|
|
35
|
-
function Copymitter(from, to, files) {
|
|
34
|
+
function Copymitter(from, to, files, overrides = {}) {
|
|
36
35
|
if (!(this instanceof Copymitter))
|
|
37
|
-
return new Copymitter(from, to, files);
|
|
36
|
+
return new Copymitter(from, to, files, overrides);
|
|
38
37
|
|
|
39
38
|
EventEmitter.call(this);
|
|
40
39
|
|
|
40
|
+
const {write = _write} = overrides;
|
|
41
|
+
|
|
42
|
+
this._write = write;
|
|
43
|
+
|
|
41
44
|
this._files = [];
|
|
42
45
|
this._errors = [];
|
|
43
46
|
this._size = 0;
|
|
@@ -123,7 +126,8 @@ Copymitter.prototype._cpAll = function() {
|
|
|
123
126
|
});
|
|
124
127
|
};
|
|
125
128
|
|
|
126
|
-
const copyDir = async (from, to) => {
|
|
129
|
+
const copyDir = async (from, to, overrides = {}) => {
|
|
130
|
+
const {write} = overrides;
|
|
127
131
|
const {mode} = await readStat(from);
|
|
128
132
|
|
|
129
133
|
await write(to, null, {
|
|
@@ -187,16 +191,19 @@ Copymitter.prototype.cpOneFile = function(from, to) {
|
|
|
187
191
|
emitFile,
|
|
188
192
|
emitDirectory,
|
|
189
193
|
countStream,
|
|
194
|
+
write: this._write,
|
|
190
195
|
});
|
|
191
196
|
|
|
192
197
|
return emitter;
|
|
193
198
|
};
|
|
194
199
|
|
|
195
|
-
async function copy(from, to, {emitError, emitFile, emitDirectory, countStream}) {
|
|
200
|
+
async function copy(from, to, {emitError, emitFile, emitDirectory, countStream, write}) {
|
|
196
201
|
const info = await readStat(from);
|
|
197
202
|
|
|
198
203
|
if (info.isDirectory()) {
|
|
199
|
-
const [copyDirError] = await tryToCatch(copyDir, from, to
|
|
204
|
+
const [copyDirError] = await tryToCatch(copyDir, from, to, {
|
|
205
|
+
write,
|
|
206
|
+
});
|
|
200
207
|
|
|
201
208
|
if (copyDirError)
|
|
202
209
|
return emitError(copyDirError);
|
|
@@ -204,7 +211,9 @@ async function copy(from, to, {emitError, emitFile, emitDirectory, countStream})
|
|
|
204
211
|
return emitDirectory();
|
|
205
212
|
}
|
|
206
213
|
|
|
207
|
-
const [error] = await tryToCatch(superCopy, from, to, [countStream]
|
|
214
|
+
const [error] = await tryToCatch(superCopy, from, to, [countStream], {
|
|
215
|
+
write,
|
|
216
|
+
});
|
|
208
217
|
|
|
209
218
|
if (error)
|
|
210
219
|
return emitError(error);
|
|
@@ -212,7 +221,8 @@ async function copy(from, to, {emitError, emitFile, emitDirectory, countStream})
|
|
|
212
221
|
emitFile();
|
|
213
222
|
}
|
|
214
223
|
|
|
215
|
-
async function superCopy(from, to, [countStream]) {
|
|
224
|
+
async function superCopy(from, to, [countStream], overrides) {
|
|
225
|
+
const {write} = overrides;
|
|
216
226
|
const [, link] = await tryToCatch(readlink, from);
|
|
217
227
|
|
|
218
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.0",
|
|
4
|
+
"type": "module",
|
|
5
5
|
"description": "copy files with emitter",
|
|
6
6
|
"main": "lib/copymitter.js",
|
|
7
7
|
"scripts": {
|
|
@@ -19,32 +19,33 @@
|
|
|
19
19
|
"currify": "^4.0.0",
|
|
20
20
|
"debug": "^4.0.1",
|
|
21
21
|
"findit2": "^2.2.3",
|
|
22
|
-
"fullstore": "^
|
|
23
|
-
"mkdirp": "^
|
|
24
|
-
"redzip": "^
|
|
22
|
+
"fullstore": "^4.0.0",
|
|
23
|
+
"mkdirp": "^3.0.1",
|
|
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
|
-
"nodemon": "^
|
|
39
|
-
"pullout": "^
|
|
40
|
-
"putout": "^
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
38
|
+
"nodemon": "^3.1.0",
|
|
39
|
+
"pullout": "^5.0.1",
|
|
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"
|
|
44
45
|
},
|
|
45
46
|
"repository": {
|
|
46
47
|
"type": "git",
|
|
47
|
-
"url": "git://github.com/coderaiser/node-copymitter.git"
|
|
48
|
+
"url": "git+https://github.com/coderaiser/node-copymitter.git"
|
|
48
49
|
},
|
|
49
50
|
"keywords": [
|
|
50
51
|
"copy",
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
"file"
|
|
55
56
|
],
|
|
56
57
|
"engines": {
|
|
57
|
-
"node": ">=
|
|
58
|
+
"node": ">=22"
|
|
58
59
|
},
|
|
59
60
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (http://coderaiser.github.io/)",
|
|
60
61
|
"license": "MIT",
|