From 13893e0a14d6c3ed64b7ca2ad528ba8d02792256 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 20 Mar 2024 13:29:19 -0700 Subject: [PATCH] Tolerate local zip files that don't exist Fixes gh-1 --- packages/antora-zip-contents-collector-extension/lib/index.js | 3 ++- .../test/zip-contents-collector-extension-test.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/antora-zip-contents-collector-extension/lib/index.js b/packages/antora-zip-contents-collector-extension/lib/index.js index 4b8183f..3624bb6 100644 --- a/packages/antora-zip-contents-collector-extension/lib/index.js +++ b/packages/antora-zip-contents-collector-extension/lib/index.js @@ -195,7 +195,8 @@ function register ({ config, downloadLog }) { logger.trace(`Skipping local file URL ${url} due to missing worktree`) continue } - return ospath.join(worktree, ...url.split('/')) + const localFile = ospath.join(worktree, ...url.split('/')) + if (fs.existsSync(localFile)) return localFile } } } diff --git a/packages/antora-zip-contents-collector-extension/test/zip-contents-collector-extension-test.js b/packages/antora-zip-contents-collector-extension/test/zip-contents-collector-extension-test.js index 7cfbe1d..2d45086 100644 --- a/packages/antora-zip-contents-collector-extension/test/zip-contents-collector-extension-test.js +++ b/packages/antora-zip-contents-collector-extension/test/zip-contents-collector-extension-test.js @@ -591,7 +591,7 @@ describe('zip contents collector extension', () => { it('should use local zip and collect files', async () => { const extensionConfig = () => ({ - locations: [{ url: 'build/${name}.zip' }, { url: 'build/${name}.zip' }], + locations: [{ url: 'build/missing/${name}.zip' }, { url: 'build/${name}.zip' }], }) const componentConfig = { include: ['start-page'] } await runScenario({