Skip to content

Commit

Permalink
fix: fix https.request call on nodejs before v10
Browse files Browse the repository at this point in the history
  • Loading branch information
3cp committed Apr 23, 2019
1 parent d92d571 commit f07b81d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/skeleton-dir.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const path = require('path');
const os = require('os');
const hostedGit = require('hosted-git-info');
const https = require('https');
const {URL} = require('url');
const gunzip = require('gunzip-maybe');
const tar = require('tar-fs');
const {info} = require('./log');
Expand Down Expand Up @@ -37,8 +38,14 @@ function isDir(dir) {
}

function getHash(tarball) {
const url = new URL(tarball);
return new Promise((resolve, reject) => {
const req = https.request(tarball, {method: 'HEAD'}, res => {
const req = https.request({
hostname: url.hostname,
path: url.pathname,
search: url.search,
method: 'HEAD'
}, res => {
if (res.statusCode === 200) {
let hash;
if (res.headers.etag) {
Expand All @@ -54,6 +61,7 @@ function getHash(tarball) {
return;
}
}

reject(new Error('Unable to get unique file name'));
});
req.on('error', reject);
Expand Down

0 comments on commit f07b81d

Please sign in to comment.