Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
[cli] Fix progress bar when uploading ios (#2502)
Browse files Browse the repository at this point in the history
  • Loading branch information
byCedric authored Aug 26, 2020
1 parent 8ce3c3b commit 4365d71
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions packages/expo-cli/src/commands/upload/utils.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
import { ExponentTools } from '@expo/xdl';
import fs from 'fs-extra';
import got from 'got';
import ProgressBar from 'progress';
import stream from 'stream';
import { promisify } from 'util';

import { createProgressTracker } from '../utils/progress';

const { spawnAsyncThrowError } = ExponentTools;
const pipeline = promisify(stream.pipeline);

export async function downloadFile(url: string, dest: string): Promise<string> {
let bar: ProgressBar | null;
let transferredSoFar = 0;
const downloadStream = got.stream(url).on('downloadProgress', progress => {
if (!bar) {
bar = new ProgressBar('Downloading [:bar] :percent :etas', {
complete: '=',
incomplete: ' ',
total: progress.total,
});
}
bar.tick(progress.transferred - transferredSoFar);
transferredSoFar = progress.transferred;
});
const downloadStream = got.stream(url).on('downloadProgress', createProgressTracker());
await pipeline(downloadStream, fs.createWriteStream(dest));
return dest;
}
Expand Down

0 comments on commit 4365d71

Please sign in to comment.