diff --git a/tests/__snapshots__/webbook.test.ts.snap b/tests/__snapshots__/webbook.test.ts.snap index 949f0e2e..f351acc3 100644 --- a/tests/__snapshots__/webbook.test.ts.snap +++ b/tests/__snapshots__/webbook.test.ts.snap @@ -273,3 +273,40 @@ exports[`generate webpub from vivliostyle.config.js 3`] = ` " `; + +exports[`generate webpub with complex copyAsset settings 1`] = ` +"/ +└─ work/ + ├─ input/ + │ ├─ .vs/ + │ │ ├─ assetA.jxl + │ │ ├─ doc.html + │ │ ├─ node_modules/ + │ │ │ └─ pkgB/ + │ │ │ ├─ a.html + │ │ │ └─ bar/ + │ │ │ └─ b.html + │ │ └─ publication.json + │ ├─ assetA.jxl + │ ├─ assetB.svg + │ ├─ cover.png + │ ├─ doc.md + │ ├─ node_modules/ + │ │ ├─ pkgA/ + │ │ │ └─ img.png + │ │ └─ pkgB/ + │ │ ├─ a.html + │ │ └─ bar/ + │ │ └─ b.html + │ ├─ package.json + │ └─ vivliostyle.config.json + └─ output/ + ├─ assetA.jxl + ├─ doc.html + ├─ node_modules/ + │ └─ pkgB/ + │ ├─ a.html + │ └─ bar/ + │ └─ b.html + └─ publication.json" +`; diff --git a/tests/webbook.test.ts b/tests/webbook.test.ts index d263ca55..47dab5a8 100644 --- a/tests/webbook.test.ts +++ b/tests/webbook.test.ts @@ -168,3 +168,37 @@ it('generate webpub from a remote HTML document', async () => { const entry = file['/work/output/work/input/index.html']; expect(format(entry as string, { parser: 'html' })).toMatchSnapshot(); }); + +it('generate webpub with complex copyAsset settings', async () => { + const config: VivliostyleConfigSchema = { + copyAsset: { + includes: [ + // The following line should also work, but under the mock environment of memfs, fast-glob does not work without '/**'. + // 'node_modules/pkgB', + 'node_modules/pkgB/**', + ], + excludes: ['cover.png'], + includeFileExtensions: ['jxl'], + excludeFileExtensions: ['svg'], + }, + entry: ['doc.md'], + output: ['/work/output'], + workspaceDir: '.vs', + }; + vol.fromJSON({ + '/work/input/vivliostyle.config.json': JSON.stringify(config), + '/work/input/package.json': '', + '/work/input/doc.md': 'yuno', + '/work/input/cover.png': '', + '/work/input/assetA.jxl': '', + '/work/input/assetB.svg': '', + '/work/input/node_modules/pkgA/img.png': '', + '/work/input/node_modules/pkgB/a.html': '', + '/work/input/node_modules/pkgB/bar/b.html': '', + }); + await build({ + configPath: '/work/input/vivliostyle.config.json', + }); + + expect(toTree(vol)).toMatchSnapshot(); +});