Replaced adm-zip with node-archiver
Sarhan Aissi committed
May 13, 2019 at 03:55 UTC
ad94f9ef08e417b95b8677af3fdd3fdd2d1d4eb3
3 files changed
+14
-7
package.json
+1
-1
@@ -79,7 +79,7 @@
79
"@babel/preset-react": "^7.0.0",
80
"@reach/menu-button": "^0.1.17",
81
"@reach/tooltip": "^0.2.0",
82
- "adm-zip": "^0.4.7",
82
+ "archiver": "^3.0.0",
83
"babel-core": "^7.0.0-bridge",
84
"babel-eslint": "^9.0.0",
85
"babel-jest": "^24.7.1",
shells/browser/shared/build.js
+12
-5
@@ -1,8 +1,8 @@
1
#!/usr/bin/env node
2
3
-const AdmZip = require('adm-zip');
3
+const archiver = require('archiver');
4
const { execSync } = require('child_process');
5
-const { readFileSync, writeFileSync } = require('fs');
5
+const { readFileSync, writeFileSync, createWriteStream } = require('fs');
6
const { copy, ensureDir, move, remove } = require('fs-extra');
7
const { join } = require('path');
8
const { getGitCommit } = require('../../utils');
@@ -70,9 +70,16 @@ const build = async (tempPath, manifestPath, manifestVersion) => {
70
writeFileSync(copiedManifestPath, JSON.stringify(manifest, null, 2));
71
72
// Pack the extension
73
- const zip = new AdmZip();
74
- zip.addLocalFolder(zipPath);
75
- zip.writeZip(join(tempPath, 'packed.zip'));
73
+ const archive = archiver('zip', { zlib: { level: 9 } });
74
+ const zipStream = createWriteStream(join(tempPath, 'packed.zip'));
75
+ await new Promise((resolve, reject) => {
76
+ archive
77
+ .directory(zipPath, false)
78
+ .on('error', err => reject(err))
79
+ .pipe(zipStream);
80
+ archive.finalize();
81
+ zipStream.on('close', () => resolve());
82
+ });
83
};
84
85
const postProcess = async (tempPath, destinationPath) => {
yarn.lock
+1
-1
@@ -1474,7 +1474,7 @@ addons-linter@1.6.1:
1474
optionalDependencies:
1475
fsevents "2.0.1"
1476
1477
-adm-zip@^0.4.7, adm-zip@~0.4.x:
1477
+adm-zip@~0.4.x:
1478
version "0.4.13"
1479
resolved "https://registry.yarnpkg.com/adm-zip/-/adm-zip-0.4.13.tgz#597e2f8cc3672151e1307d3e95cddbc75672314a"
1480
integrity sha512-fERNJX8sOXfel6qCBCMPvZLzENBEhZTzKqg6vrOW5pvoEaQuJhRU4ndTAh6lHOxn1I6jnz2NHra56ZODM751uw==