Skip to content

Commit

Permalink
[INTERNAL] manifestBundler: Use "yazl" instead of "archiver" for zip
Browse files Browse the repository at this point in the history
Archiver is a quite heavy dependency (see #63) and can be replaced with
"yazl".
Tests have also been adopted from adm-zip to extract-zip (which uses
"yauzl" under the hood).

Fixes: #63
  • Loading branch information
matz3 committed Jan 3, 2019
1 parent 0d5cf50 commit b760a43
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 259 deletions.
12 changes: 6 additions & 6 deletions lib/processors/bundlers/manifestBundler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require("path");
const archiver = require("archiver");
const yazl = require("yazl");
const resourceFactory = require("@ui5/fs").resourceFactory;

/**
Expand Down Expand Up @@ -97,18 +97,18 @@ module.exports = ({resources, options}) => {

return archiveContent;
}).then((archiveContent) => new Promise((resolve) => {
const zip = archiver("zip", {zlib: {level: 9}});
const regex = new RegExp(`^/resources/${options.namespace}`);
const zip = new yazl.ZipFile();
const regex = new RegExp(`^/resources/${options.namespace}/`);
archiveContent.forEach((content, path) => {
// Root-project only: Remove namespace prefix if given
const normalizedPath = path.replace(regex, "");
zip.append(content, {name: normalizedPath});
zip.addBuffer(content, normalizedPath);
});
zip.finalize();
zip.end();

const res = resourceFactory.createResource({
path: "/" + options.bundleName,
stream: zip
stream: zip.outputStream
});
resolve([res]);
}));
Expand Down
Loading

0 comments on commit b760a43

Please sign in to comment.