message: Handled redirect while requesting typings from unpkg
diff: @@ -48,17 +48,26 @@ function httpGetJson(url) {
  });
  }
  -function downloadTypingsToFile(typingsFilePath, version) {
  +function downloadFile(urlString, filePath) {
  return new Promise((resolve, reject) => {
  let file;
  - const versionTypingsUrl = `https://unpkg.com/lightweight-charts@${version}/dist/typings.d.ts`;
  - const request = https.get(versionTypingsUrl, response => {
  +
  + const url = new URL(urlString);
  +
  + const request = https.get(url, response => {
  + if (response.statusCode >= 300 && response.statusCode < 400 && response.headers.location !== undefined) {
  + // handling redirect
  + url.pathname = response.headers.location;
  + downloadFile(url.toString(), filePath).then(resolve, reject);
  + return;
  + }
  +
  if (response.statusCode && (response.statusCode < 100 || response.statusCode > 299)) {
  - reject(new Error(`Cannot download typings "${versionTypingsUrl}", error code=${response.statusCode}`));
  + reject(new Error(`Cannot download file "${urlString}", error code=${response.statusCode}`));
  return;
  }
  - file = fs.createWriteStream(typingsFilePath);
  + file = fs.createWriteStream(filePath);
  file.on('finish', () => {
  file.close(resolve);
  });
  @@ -76,6 +85,13 @@ function downloadTypingsToFile(typingsFilePath, version) {
  });
  }
  +function downloadTypingsToFile(typingsFilePath, version) {
  + return downloadFile(
  + `https://unpkg.com/lightweight-charts@${version}/dist/typings.d.ts`,
  + typingsFilePath
  + );
  +}
  +
  async function downloadTypingsFromUnpkg(version) {
  const typingsFilePath = path.resolve(cacheDir, `./v${version}.d.ts`);
  