@antora/file-publisher
Advanced tools
Comparing version 3.0.2 to 3.0.3
@@ -65,3 +65,3 @@ 'use strict' | ||
// Q: add getPublishableFiles / getOutFiles; return a stream? or getOutFilesAsStream? | ||
const filesToPublish = (Array.isArray(catalogs) ? catalogs : [catalogs]).reduce((accum, catalog) => { | ||
const files = (Array.isArray(catalogs) ? catalogs : [catalogs]).reduce((accum, catalog) => { | ||
// the check for getAll on catalogs is @deprecated; scheduled to be removed in Antora 4 | ||
@@ -72,3 +72,4 @@ accum.push(...(catalog.getFiles || catalog.getAll).apply(catalog).filter((file) => file.out)) | ||
return Promise.all(publishers.map((publish) => publish(new ReadableOutputFileArray(filesToPublish), playbook))) | ||
const cloneStreams = publishers.length > 1 | ||
return Promise.all(publishers.map((publish) => publish(new ReadableOutputFileArray(files, cloneStreams), playbook))) | ||
} | ||
@@ -75,0 +76,0 @@ |
@@ -13,5 +13,5 @@ 'use strict' | ||
class ReadableOutputFileArray extends Readable { | ||
constructor (array) { | ||
constructor (array, cloneStreams) { | ||
super({ objectMode: true }) | ||
this._array = array.slice().reverse() | ||
this._array = array.map((it) => toOutputFile(it, cloneStreams)).reverse() | ||
} | ||
@@ -24,3 +24,3 @@ | ||
if (next === undefined) break | ||
this.push(toOutputFile(next)) | ||
this.push(next) | ||
} | ||
@@ -31,7 +31,18 @@ if (size > -1) this.push(null) | ||
function toOutputFile (file) { | ||
// Q: do we also need to clone contents and stat? | ||
return new File({ contents: file.contents, path: file.out.path, stat: file.stat }) | ||
// Q: do we also need to clone stat? | ||
function toOutputFile (file, cloneStreams) { | ||
const contents = file.contents | ||
const outputFile = new File({ contents, path: file.out.path, stat: file.stat }) | ||
if (cloneStreams && outputFile.isStream()) { | ||
const outputFileContents = outputFile.contents | ||
if (outputFileContents !== contents) { | ||
// NOTE: workaround for @antora/lunr-extension <= 1.0.0-alpha.8 | ||
if (!('get' in (Object.getOwnPropertyDescriptor(file, 'contents') || {}))) file.contents = outputFileContents | ||
} | ||
// NOTE: even the last occurrence must be cloned when using vinyl-fs even though cloneable-readable claims otherwise | ||
outputFile.contents = outputFileContents.clone() | ||
} | ||
return outputFile | ||
} | ||
module.exports = ReadableOutputFileArray |
{ | ||
"name": "@antora/file-publisher", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"description": "Publishes the publishable files in the virtual file catalog(s) to the destination(s) specified in the playbook.", | ||
@@ -5,0 +5,0 @@ "license": "MPL-2.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
10655
195