Skip to content

Commit 6570975

Browse files
authored
esm: node v18+ required (#193)
* conversion to esm * Delete .github/workflows/npmpublish.yml.save
1 parent c903277 commit 6570975

25 files changed

+1542
-3086
lines changed

.github/workflows/nodejs.yml

+17-17
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ jobs:
1414

1515
strategy:
1616
matrix:
17-
node-version: [14.x, 16.x, 18.x, 20.x]
17+
node-version: [18.x, 20.x]
1818

1919
steps:
20-
- uses: actions/[email protected]
21-
- name: Use Node.js ${{ matrix.node-version }}
22-
uses: actions/[email protected]
23-
with:
24-
node-version: ${{ matrix.node-version }}
25-
- name: npm install and test
26-
run: |
27-
npm ci
28-
npm test
29-
env:
30-
CI: true
31-
- name: Archive production artifacts
32-
uses: actions/upload-artifact@v4
33-
with:
34-
name: tmp-zip-node-v${{ matrix.node-version }}
35-
path: tmp/*.zip
20+
- uses: actions/[email protected]
21+
- name: Use Node.js ${{ matrix.node-version }}
22+
uses: actions/[email protected]
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
- name: npm install and test
26+
run: |
27+
npm ci
28+
npm test
29+
env:
30+
CI: true
31+
- name: Archive production artifacts
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: tmp-zip-node-v${{ matrix.node-version }}
35+
path: tmp/*.zip

.github/workflows/npmpublish.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- uses: actions/[email protected]
1212
- uses: actions/[email protected]
1313
with:
14-
node-version: 16
14+
node-version: 20
1515
- run: npm ci
1616
- run: npm test
1717

@@ -22,7 +22,7 @@ jobs:
2222
- uses: actions/[email protected]
2323
- uses: actions/[email protected]
2424
with:
25-
node-version: 16
25+
node-version: 20
2626
registry-url: https://registry.npmjs.org/
2727
- run: npm ci
2828
- run: npm publish

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore artifacts:
2+
build
3+
coverage

CHANGELOG.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313
**5.0.0** — <small>_September 2, 2023_</small> — [Diff](https://github.com/archiverjs/node-compress-commons/compare/4.1.2...5.0.0)
1414

15-
1615
**4.1.2** — <small>_September 2, 2023_</small> — [Diff](https://github.com/archiverjs/node-compress-commons/compare/4.1.1...4.1.2)
1716

1817
**4.1.1** — <small>_May 30th, 2021_</small> — [Diff](https://github.com/archiverjs/node-compress-commons/compare/4.1.0...4.1.1)
1918

2019
### Maintenance
20+
2121
- Bump mocha from 8.2.1 to 8.4.0 (#70)
2222
- Bump crc32-stream from 4.0.1 to 4.0.2 (#59)
2323
- Bump y18n from 4.0.0 to 4.0.1 (#69)
@@ -36,17 +36,17 @@
3636

3737
**4.0.1** — <small>_July 20, 2020_</small> — [Diff](https://github.com/archiverjs/node-compress-commons/compare/4.0.0...4.0.1)
3838

39-
* Bump crc32-stream from 3.0.1 to 4.0.0 (#43) @dependabot
39+
- Bump crc32-stream from 3.0.1 to 4.0.0 (#43) @dependabot
4040

4141
**4.0.0** — <small>_July 18, 2020_</small> — [Diff](https://github.com/archiverjs/node-compress-commons/compare/3.0.0...4.0.0)
4242

43-
* Bump mocha from 5.2.0 to 8.0.1 (#36) @dependabot
44-
* Bump readable-stream from 2.3.7 to 3.6.0 (#39) @dependabot
45-
* Bump actions/setup-node from v1 to v2.1.0 (#41) @dependabot
46-
* Bump rimraf from 2.7.1 to 3.0.2 (#38) @dependabot
47-
* Bump mkdirp from 0.5.5 to 1.0.4 (#37) @dependabot
48-
* Bump actions/checkout from v1 to v2.3.1 (#40) @dependabot
49-
* remove support for node < 10 (#42) @ctalkington
43+
- Bump mocha from 5.2.0 to 8.0.1 (#36) @dependabot
44+
- Bump readable-stream from 2.3.7 to 3.6.0 (#39) @dependabot
45+
- Bump actions/setup-node from v1 to v2.1.0 (#41) @dependabot
46+
- Bump rimraf from 2.7.1 to 3.0.2 (#38) @dependabot
47+
- Bump mkdirp from 0.5.5 to 1.0.4 (#37) @dependabot
48+
- Bump actions/checkout from v1 to v2.3.1 (#40) @dependabot
49+
- remove support for node < 10 (#42) @ctalkington
5050

5151
**3.0.0** — <small>_April 14, 2020_</small> — [Diff](https://github.com/archiverjs/node-compress-commons/compare/2.1.1...3.0.0)
5252

CONTRIBUTING.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
#### Code Style Guide
44

5-
* code should be indented with 2 spaces
6-
* single quotes should be used where feasible
7-
* commas should be followed by a single space (function params, etc)
8-
* variable declaration should include `var`, [no multiple declarations](http://benalman.com/news/2012/05/multiple-var-statements-javascript/)
5+
- code should be indented with 2 spaces
6+
- single quotes should be used where feasible
7+
- commas should be followed by a single space (function params, etc)
8+
- variable declaration should include `var`, [no multiple declarations](http://benalman.com/news/2012/05/multiple-var-statements-javascript/)
99

1010
#### Tests
1111

12-
* tests should be added to the nodeunit configs in `tests/`
13-
* tests can be run with `npm test`
14-
* see existing tests for guidance
12+
- tests should be added to the nodeunit configs in `tests/`
13+
- tests can be run with `npm test`
14+
- see existing tests for guidance

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ You can also use `npm install https://github.com/archiverjs/node-compress-common
2222

2323
Concept inspired by [Apache Commons Compress](http://commons.apache.org/proper/commons-compress/)&trade;.
2424

25-
Some logic derived from [Apache Commons Compress](http://commons.apache.org/proper/commons-compress/)&trade; and [OpenJDK 7](http://openjdk.java.net/).
25+
Some logic derived from [Apache Commons Compress](http://commons.apache.org/proper/commons-compress/)&trade; and [OpenJDK 7](http://openjdk.java.net/).

lib/archivers/archive-entry.js

+6-16
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
1-
/**
2-
* node-compress-commons
3-
*
4-
* Copyright (c) 2014 Chris Talkington, contributors.
5-
* Licensed under the MIT license.
6-
* https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT
7-
*/
8-
var ArchiveEntry = module.exports = function() {};
9-
10-
ArchiveEntry.prototype.getName = function() {};
11-
12-
ArchiveEntry.prototype.getSize = function() {};
13-
14-
ArchiveEntry.prototype.getLastModifiedDate = function() {};
15-
16-
ArchiveEntry.prototype.isDirectory = function() {};
1+
export default class ArchiveEntry {
2+
getName() {}
3+
getSize() {}
4+
getLastModifiedDate() {}
5+
isDirectory() {}
6+
}
+79-99
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,98 @@
1-
/**
2-
* node-compress-commons
3-
*
4-
* Copyright (c) 2014 Chris Talkington, contributors.
5-
* Licensed under the MIT license.
6-
* https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT
7-
*/
8-
var inherits = require('util').inherits;
9-
var isStream = require('is-stream');
10-
var Transform = require('readable-stream').Transform;
11-
12-
var ArchiveEntry = require('./archive-entry');
13-
var util = require('../util');
14-
15-
var ArchiveOutputStream = module.exports = function(options) {
16-
if (!(this instanceof ArchiveOutputStream)) {
17-
return new ArchiveOutputStream(options);
1+
import { inherits } from "util";
2+
import { isStream } from "is-stream";
3+
import { Transform } from "readable-stream";
4+
import ArchiveEntry from "./archive-entry.js";
5+
import { normalizeInputSource } from "../util/index.js";
6+
7+
export default class ArchiveOutputStream extends Transform {
8+
constructor(options) {
9+
super(options);
10+
11+
this.offset = 0;
12+
this._archive = {
13+
finish: false,
14+
finished: false,
15+
processing: false,
16+
};
1817
}
1918

20-
Transform.call(this, options);
21-
22-
this.offset = 0;
23-
this._archive = {
24-
finish: false,
25-
finished: false,
26-
processing: false
27-
};
28-
};
29-
30-
inherits(ArchiveOutputStream, Transform);
31-
32-
ArchiveOutputStream.prototype._appendBuffer = function(zae, source, callback) {
33-
// scaffold only
34-
};
35-
36-
ArchiveOutputStream.prototype._appendStream = function(zae, source, callback) {
37-
// scaffold only
38-
};
39-
40-
ArchiveOutputStream.prototype._emitErrorCallback = function(err) {
41-
if (err) {
42-
this.emit('error', err);
19+
_appendBuffer(zae, source, callback) {
20+
// scaffold only
4321
}
44-
};
45-
46-
ArchiveOutputStream.prototype._finish = function(ae) {
47-
// scaffold only
48-
};
4922

50-
ArchiveOutputStream.prototype._normalizeEntry = function(ae) {
51-
// scaffold only
52-
};
53-
54-
ArchiveOutputStream.prototype._transform = function(chunk, encoding, callback) {
55-
callback(null, chunk);
56-
};
23+
_appendStream(zae, source, callback) {
24+
// scaffold only
25+
}
5726

58-
ArchiveOutputStream.prototype.entry = function(ae, source, callback) {
59-
source = source || null;
27+
_emitErrorCallback = function (err) {
28+
if (err) {
29+
this.emit("error", err);
30+
}
31+
};
6032

61-
if (typeof callback !== 'function') {
62-
callback = this._emitErrorCallback.bind(this);
33+
_finish(ae) {
34+
// scaffold only
6335
}
6436

65-
if (!(ae instanceof ArchiveEntry)) {
66-
callback(new Error('not a valid instance of ArchiveEntry'));
67-
return;
37+
_normalizeEntry(ae) {
38+
// scaffold only
6839
}
6940

70-
if (this._archive.finish || this._archive.finished) {
71-
callback(new Error('unacceptable entry after finish'));
72-
return;
41+
_transform(chunk, encoding, callback) {
42+
callback(null, chunk);
7343
}
7444

75-
if (this._archive.processing) {
76-
callback(new Error('already processing an entry'));
77-
return;
45+
entry(ae, source, callback) {
46+
source = source || null;
47+
if (typeof callback !== "function") {
48+
callback = this._emitErrorCallback.bind(this);
49+
}
50+
if (!(ae instanceof ArchiveEntry)) {
51+
callback(new Error("not a valid instance of ArchiveEntry"));
52+
return;
53+
}
54+
if (this._archive.finish || this._archive.finished) {
55+
callback(new Error("unacceptable entry after finish"));
56+
return;
57+
}
58+
if (this._archive.processing) {
59+
callback(new Error("already processing an entry"));
60+
return;
61+
}
62+
this._archive.processing = true;
63+
this._normalizeEntry(ae);
64+
this._entry = ae;
65+
source = normalizeInputSource(source);
66+
if (Buffer.isBuffer(source)) {
67+
this._appendBuffer(ae, source, callback);
68+
} else if (isStream(source)) {
69+
this._appendStream(ae, source, callback);
70+
} else {
71+
this._archive.processing = false;
72+
callback(
73+
new Error("input source must be valid Stream or Buffer instance"),
74+
);
75+
return;
76+
}
77+
return this;
7878
}
7979

80-
this._archive.processing = true;
81-
this._normalizeEntry(ae);
82-
this._entry = ae;
83-
84-
source = util.normalizeInputSource(source);
85-
86-
if (Buffer.isBuffer(source)) {
87-
this._appendBuffer(ae, source, callback);
88-
} else if (isStream(source)) {
89-
this._appendStream(ae, source, callback);
90-
} else {
91-
this._archive.processing = false;
92-
callback(new Error('input source must be valid Stream or Buffer instance'));
93-
return;
80+
finish() {
81+
if (this._archive.processing) {
82+
this._archive.finish = true;
83+
return;
84+
}
85+
this._finish();
9486
}
9587

96-
return this;
97-
};
98-
99-
ArchiveOutputStream.prototype.finish = function() {
100-
if (this._archive.processing) {
101-
this._archive.finish = true;
102-
return;
88+
getBytesWritten() {
89+
return this.offset;
10390
}
10491

105-
this._finish();
106-
};
107-
108-
ArchiveOutputStream.prototype.getBytesWritten = function() {
109-
return this.offset;
110-
};
111-
112-
ArchiveOutputStream.prototype.write = function(chunk, cb) {
113-
if (chunk) {
114-
this.offset += chunk.length;
92+
write(chunk, cb) {
93+
if (chunk) {
94+
this.offset += chunk.length;
95+
}
96+
return super.write(chunk, cb);
11597
}
116-
117-
return Transform.prototype.write.call(this, chunk, cb);
118-
};
98+
}

0 commit comments

Comments
 (0)