@antora/file-publisher
Advanced tools
Comparing version 3.2.0-alpha.5 to 3.2.0-alpha.6
@@ -11,4 +11,5 @@ 'use strict' | ||
constructor (original, opts) { | ||
super(Object.assign({}, opts, { objectMode: original._readableState.objectMode })) | ||
super(Object.assign({}, opts, { objectMode: original.readableObjectMode })) | ||
forwardDestroy((this._original = original), this) | ||
this.setMaxListeners(0) | ||
this._numStreams = 1 | ||
@@ -31,3 +32,3 @@ this._hasListener = true | ||
constructor (cloneable, opts) { | ||
super(Object.assign({}, opts, { objectMode: cloneable._readableState.objectMode })) | ||
super(Object.assign({}, opts, { objectMode: cloneable.readableObjectMode })) | ||
forwardDestroy((this._cloneable = cloneable), this) | ||
@@ -72,3 +73,3 @@ Object.defineProperty(cloneable, 'resume', { value: invariably.void, configurable: true }) | ||
function pipeIfFulfilled (cloneable) { | ||
if (--cloneable._numStreams !== 0 || cloneable._readableState.destroyed) return | ||
if (--cloneable._numStreams !== 0 || cloneable.destroyed) return | ||
cloneable._original.pipe(cloneable) | ||
@@ -75,0 +76,0 @@ cloneable._original = undefined |
'use strict' | ||
const CloneableReadable = require('./cloneable-readable') | ||
const { Readable } = require('node:stream') | ||
const Stream = require('node:stream') | ||
const { Readable } = Stream | ||
const Vinyl = require('vinyl') | ||
@@ -31,21 +32,24 @@ | ||
function toOutputFile (file, cloneStreams) { | ||
const contents = file.contents | ||
const outputFile = new File({ contents, path: file.out.path, stat: file.stat }) | ||
if (cloneStreams && isStream(contents)) { | ||
// NOTE: guard in case contents is created on access (needed for @antora/lunr-extension <= 1.0.0-alpha.8) | ||
if ((Object.getOwnPropertyDescriptor(file, 'contents') || { writable: true }).writable) { | ||
const oContents = | ||
contents instanceof CloneableReadable || typeof contents.clone === 'function' | ||
? contents | ||
: (file.contents = new CloneableReadable(contents)) | ||
outputFile.contents = oContents._allocated ? oContents.clone() : (oContents._allocated = true) && oContents | ||
let contents = file.contents | ||
if (contents instanceof Stream) { | ||
// NOTE: use guard in case contents is created on access (needed for @antora/lunr-extension <= 1.0.0-alpha.8) | ||
if (cloneStreams && (Object.getOwnPropertyDescriptor(file, 'contents') || { writable: true }).writable) { | ||
if (contents instanceof CloneableReadable) { | ||
contents._claimed ? (contents = contents.clone()) : (contents._claimed = true) | ||
} else if (typeof contents.clone === 'function' /* vinyl < 4 compat */) { | ||
contents = wrapLegacyStream(contents._claimed ? contents.clone() : (contents._claimed = true) && contents) | ||
} else { | ||
file.contents = ((contents = new CloneableReadable(contents))._claimed = true) && contents | ||
} | ||
} else { | ||
contents = wrapLegacyStream(contents) | ||
} | ||
} | ||
return outputFile | ||
return new File({ contents, path: file.out.path, stat: file.stat }) | ||
} | ||
function isStream (obj) { | ||
return obj && typeof obj.pipe === 'function' | ||
function wrapLegacyStream (contents) { | ||
return contents instanceof Readable && Symbol.asyncIterator in contents ? contents : Readable.wrap(contents) | ||
} | ||
module.exports = ReadableOutputFileArray |
{ | ||
"name": "@antora/file-publisher", | ||
"version": "3.2.0-alpha.5", | ||
"version": "3.2.0-alpha.6", | ||
"description": "Publishes the publishable files in the virtual file catalog(s) to the destination(s) specified in the playbook.", | ||
@@ -31,2 +31,5 @@ "license": "MPL-2.0", | ||
}, | ||
"devDependencies": { | ||
"cloneable-readable": "~1.1" | ||
}, | ||
"engines": { | ||
@@ -33,0 +36,0 @@ "node": ">=18.0.0" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17798
360
1