Skip to content

Commit

Permalink
Remove a dependency of the installation process
Browse files Browse the repository at this point in the history
  • Loading branch information
jbdemonte committed Aug 16, 2019
1 parent 7e29c38 commit 88c9158
Show file tree
Hide file tree
Showing 3 changed files with 484 additions and 522 deletions.
9 changes: 4 additions & 5 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "p7zip",
"version": "4.0.0",
"version": "4.1.0",
"description": "A node wrapper for 7z including latest version of 7za",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -37,15 +37,14 @@
],
"license": "MIT",
"dependencies": {
"decompress": "^4.0.0",
"request": "^2.88.0"
"decompress": "^4.0.0"
},
"devDependencies": {
"@gojob/tslint-config": "^1.0.0",
"@types/jest": "^24.0.17",
"@types/node": "^12.7.1",
"@types/node": "^12.7.2",
"coveralls": "^3.0.6",
"jest": "^24.8.0",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"ts-jest": "^24.0.2",
"ts-node": "^8.3.0",
Expand Down
25 changes: 16 additions & 9 deletions scripts/install.js
Expand Up @@ -5,7 +5,7 @@ const bin = 'bin/7za';
const decompress = require('decompress');
const fs = require('fs');
const path = require('path');
const request = require('request');
const { get } = require('https');
const spawn = require('child_process').spawn;

/**
Expand All @@ -15,17 +15,24 @@ const spawn = require('child_process').spawn;
function wget(uri) {
console.log('Downloading ' + uri);
return new Promise((resolve, reject) => {
request({uri, encoding: null}, (err, { body }) => {
if (err) {
console.error('Error downloading file: ');
console.error(err);
return reject();
get(uri, response => {
const { statusCode, headers } = response;
if (statusCode === 302) {
wget(headers.location)
.then(resolve)
.catch(reject)
} else {
let buffer = Buffer.alloc(0);
response.on('data', (chunk) => {
buffer = Buffer.concat([buffer, chunk]);
});
response.on('end', () => resolve(buffer));
}
resolve(body);
});
});
}).on('error', reject);
})
}


/**
* recursive rmdir
*/
Expand Down

0 comments on commit 88c9158

Please sign in to comment.