-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* conversion to esm * Delete .github/workflows/npmpublish.yml.save
- Loading branch information
1 parent
c903277
commit 6570975
Showing
25 changed files
with
1,542 additions
and
3,086 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,22 +14,22 @@ jobs: | |
|
||
strategy: | ||
matrix: | ||
node-version: [14.x, 16.x, 18.x, 20.x] | ||
node-version: [18.x, 20.x] | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/[email protected] | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: npm install and test | ||
run: | | ||
npm ci | ||
npm test | ||
env: | ||
CI: true | ||
- name: Archive production artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: tmp-zip-node-v${{ matrix.node-version }} | ||
path: tmp/*.zip | ||
- uses: actions/[email protected] | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/[email protected] | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: npm install and test | ||
run: | | ||
npm ci | ||
npm test | ||
env: | ||
CI: true | ||
- name: Archive production artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: tmp-zip-node-v${{ matrix.node-version }} | ||
path: tmp/*.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ jobs: | |
- uses: actions/[email protected] | ||
- uses: actions/[email protected] | ||
with: | ||
node-version: 16 | ||
node-version: 20 | ||
- run: npm ci | ||
- run: npm test | ||
|
||
|
@@ -22,7 +22,7 @@ jobs: | |
- uses: actions/[email protected] | ||
- uses: actions/[email protected] | ||
with: | ||
node-version: 16 | ||
node-version: 20 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: npm ci | ||
- run: npm publish | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Ignore artifacts: | ||
build | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,6 @@ | ||
/** | ||
* node-compress-commons | ||
* | ||
* Copyright (c) 2014 Chris Talkington, contributors. | ||
* Licensed under the MIT license. | ||
* https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT | ||
*/ | ||
var ArchiveEntry = module.exports = function() {}; | ||
|
||
ArchiveEntry.prototype.getName = function() {}; | ||
|
||
ArchiveEntry.prototype.getSize = function() {}; | ||
|
||
ArchiveEntry.prototype.getLastModifiedDate = function() {}; | ||
|
||
ArchiveEntry.prototype.isDirectory = function() {}; | ||
export default class ArchiveEntry { | ||
getName() {} | ||
getSize() {} | ||
getLastModifiedDate() {} | ||
isDirectory() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,118 +1,98 @@ | ||
/** | ||
* node-compress-commons | ||
* | ||
* Copyright (c) 2014 Chris Talkington, contributors. | ||
* Licensed under the MIT license. | ||
* https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT | ||
*/ | ||
var inherits = require('util').inherits; | ||
var isStream = require('is-stream'); | ||
var Transform = require('readable-stream').Transform; | ||
|
||
var ArchiveEntry = require('./archive-entry'); | ||
var util = require('../util'); | ||
|
||
var ArchiveOutputStream = module.exports = function(options) { | ||
if (!(this instanceof ArchiveOutputStream)) { | ||
return new ArchiveOutputStream(options); | ||
import { inherits } from "util"; | ||
import { isStream } from "is-stream"; | ||
import { Transform } from "readable-stream"; | ||
import ArchiveEntry from "./archive-entry.js"; | ||
import { normalizeInputSource } from "../util/index.js"; | ||
|
||
export default class ArchiveOutputStream extends Transform { | ||
constructor(options) { | ||
super(options); | ||
|
||
this.offset = 0; | ||
this._archive = { | ||
finish: false, | ||
finished: false, | ||
processing: false, | ||
}; | ||
} | ||
|
||
Transform.call(this, options); | ||
|
||
this.offset = 0; | ||
this._archive = { | ||
finish: false, | ||
finished: false, | ||
processing: false | ||
}; | ||
}; | ||
|
||
inherits(ArchiveOutputStream, Transform); | ||
|
||
ArchiveOutputStream.prototype._appendBuffer = function(zae, source, callback) { | ||
// scaffold only | ||
}; | ||
|
||
ArchiveOutputStream.prototype._appendStream = function(zae, source, callback) { | ||
// scaffold only | ||
}; | ||
|
||
ArchiveOutputStream.prototype._emitErrorCallback = function(err) { | ||
if (err) { | ||
this.emit('error', err); | ||
_appendBuffer(zae, source, callback) { | ||
// scaffold only | ||
} | ||
}; | ||
|
||
ArchiveOutputStream.prototype._finish = function(ae) { | ||
// scaffold only | ||
}; | ||
|
||
ArchiveOutputStream.prototype._normalizeEntry = function(ae) { | ||
// scaffold only | ||
}; | ||
|
||
ArchiveOutputStream.prototype._transform = function(chunk, encoding, callback) { | ||
callback(null, chunk); | ||
}; | ||
_appendStream(zae, source, callback) { | ||
// scaffold only | ||
} | ||
|
||
ArchiveOutputStream.prototype.entry = function(ae, source, callback) { | ||
source = source || null; | ||
_emitErrorCallback = function (err) { | ||
if (err) { | ||
this.emit("error", err); | ||
} | ||
}; | ||
|
||
if (typeof callback !== 'function') { | ||
callback = this._emitErrorCallback.bind(this); | ||
_finish(ae) { | ||
// scaffold only | ||
} | ||
|
||
if (!(ae instanceof ArchiveEntry)) { | ||
callback(new Error('not a valid instance of ArchiveEntry')); | ||
return; | ||
_normalizeEntry(ae) { | ||
// scaffold only | ||
} | ||
|
||
if (this._archive.finish || this._archive.finished) { | ||
callback(new Error('unacceptable entry after finish')); | ||
return; | ||
_transform(chunk, encoding, callback) { | ||
callback(null, chunk); | ||
} | ||
|
||
if (this._archive.processing) { | ||
callback(new Error('already processing an entry')); | ||
return; | ||
entry(ae, source, callback) { | ||
source = source || null; | ||
if (typeof callback !== "function") { | ||
callback = this._emitErrorCallback.bind(this); | ||
} | ||
if (!(ae instanceof ArchiveEntry)) { | ||
callback(new Error("not a valid instance of ArchiveEntry")); | ||
return; | ||
} | ||
if (this._archive.finish || this._archive.finished) { | ||
callback(new Error("unacceptable entry after finish")); | ||
return; | ||
} | ||
if (this._archive.processing) { | ||
callback(new Error("already processing an entry")); | ||
return; | ||
} | ||
this._archive.processing = true; | ||
this._normalizeEntry(ae); | ||
this._entry = ae; | ||
source = normalizeInputSource(source); | ||
if (Buffer.isBuffer(source)) { | ||
this._appendBuffer(ae, source, callback); | ||
} else if (isStream(source)) { | ||
this._appendStream(ae, source, callback); | ||
} else { | ||
this._archive.processing = false; | ||
callback( | ||
new Error("input source must be valid Stream or Buffer instance"), | ||
); | ||
return; | ||
} | ||
return this; | ||
} | ||
|
||
this._archive.processing = true; | ||
this._normalizeEntry(ae); | ||
this._entry = ae; | ||
|
||
source = util.normalizeInputSource(source); | ||
|
||
if (Buffer.isBuffer(source)) { | ||
this._appendBuffer(ae, source, callback); | ||
} else if (isStream(source)) { | ||
this._appendStream(ae, source, callback); | ||
} else { | ||
this._archive.processing = false; | ||
callback(new Error('input source must be valid Stream or Buffer instance')); | ||
return; | ||
finish() { | ||
if (this._archive.processing) { | ||
this._archive.finish = true; | ||
return; | ||
} | ||
this._finish(); | ||
} | ||
|
||
return this; | ||
}; | ||
|
||
ArchiveOutputStream.prototype.finish = function() { | ||
if (this._archive.processing) { | ||
this._archive.finish = true; | ||
return; | ||
getBytesWritten() { | ||
return this.offset; | ||
} | ||
|
||
this._finish(); | ||
}; | ||
|
||
ArchiveOutputStream.prototype.getBytesWritten = function() { | ||
return this.offset; | ||
}; | ||
|
||
ArchiveOutputStream.prototype.write = function(chunk, cb) { | ||
if (chunk) { | ||
this.offset += chunk.length; | ||
write(chunk, cb) { | ||
if (chunk) { | ||
this.offset += chunk.length; | ||
} | ||
return super.write(chunk, cb); | ||
} | ||
|
||
return Transform.prototype.write.call(this, chunk, cb); | ||
}; | ||
} |
Oops, something went wrong.