/* Guards the readdir-glob -> minimatch override in client/package.json. * * The override forces minimatch 11 where readdir-glob asks for ^10. An * incompatible API would only show up at runtime, in the one place that walks a * directory through readdir-glob: archiver's directory(), which exceljs uses to * build an xlsx. This archives a small tree and checks the archive holds both * files, so a broken override fails here rather than in a user's download. */ const fs = require('fs') const os = require('os') const path = require('path') const { ZipArchive } = require('archiver') const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'dc-arch-')) fs.writeFileSync(path.join(dir, 'a.txt'), 'hello') fs.mkdirSync(path.join(dir, 'sub')) fs.writeFileSync(path.join(dir, 'sub', 'b.txt'), 'world') const out = path.join(os.tmpdir(), 'dc-arch-test.zip') const sink = fs.createWriteStream(out) const archive = new ZipArchive({ zlib: { level: 9 } }) archive.on('error', (err) => { console.error('archiver error: ' + err.message) process.exit(1) }) sink.on('close', () => { const bytes = fs.statSync(out).size /* two tiny files plus central directory; an empty or truncated archive is far smaller, which is what a broken glob matcher would produce */ if (bytes < 200) { console.error('archive is too small: ' + bytes + ' bytes') process.exit(1) } console.log('archiver directory walk ok: ' + bytes + ' bytes') }) archive.pipe(sink) archive.directory(dir, false) archive.finalize()