Skip to content

Commit

Permalink
Use unzip-crx instead of cross-unzip and 7-zip (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
motin authored and MarshallOfSound committed Nov 14, 2019
1 parent e9471f9 commit 3e37415
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@
"spec-xunit-file": "0.0.1-3"
},
"dependencies": {
"7zip": "0.0.6",
"cross-unzip": "0.0.2",
"rimraf": "^2.5.2",
"semver": "^5.3.0"
"semver": "^5.3.0",
"unzip-crx": "^0.2.0"
},
"babel": {
"presets": [
Expand Down
11 changes: 6 additions & 5 deletions src/downloadChromeExtension.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs';
import path from 'path';
import rimraf from 'rimraf';
import unzip from 'cross-unzip';
import unzip from 'unzip-crx';

import { getPath, downloadFile, changePermissions } from './utils';

Expand All @@ -19,12 +19,13 @@ const downloadChromeExtension = (chromeStoreID, forceDownload, attempts = 5) =>
const fileURL = `https://clients2.google.com/service/update2/crx?response=redirect&x=id%3D${chromeStoreID}%26uc&prodversion=32`; // eslint-disable-line
const filePath = path.resolve(`${extensionFolder}.crx`);
downloadFile(fileURL, filePath).then(() => {
unzip(filePath, extensionFolder, (err) => {
if (err && !fs.existsSync(path.resolve(extensionFolder, 'manifest.json'))) {
return reject(err);
}
unzip(filePath, extensionFolder).then(() => {
changePermissions(extensionFolder, 755);
resolve(extensionFolder);
}).catch((err) => {
if (!fs.existsSync(path.resolve(extensionFolder, 'manifest.json'))) {
return reject(err);
}
});
}).catch((err) => {
console.log(`Failed to fetch extension, trying ${attempts - 1} more times`); // eslint-disable-line
Expand Down

0 comments on commit 3e37415

Please sign in to comment.