@@ -56,10 +56,8 @@ export async function downloadToString(url: string): Promise<string> {
5656 return result . toString ( )
5757}
5858
59- export async function downloadFile ( url : string , options : string | DownloadOptions ) : Promise < string | null > {
60- if ( isString ( options ) ) {
61- options = { path : options } ;
62- }
59+ export async function downloadFile ( url : string , opts : string | DownloadOptions ) : Promise < string | null > {
60+ const options = isString ( opts ) ? { path : opts } : opts ;
6361
6462 const result = createWriteStream ( options . path as string ) ;
6563 const sum = await downloadToStream ( url , result , options . hashType ) ;
@@ -69,10 +67,9 @@ export async function downloadFile(url: string, options: string | DownloadOption
6967 return sum ;
7068}
7169
72- export async function downloadTgz ( url : string , options : string | DownloadOptions ) : Promise < string | null > {
73- if ( isString ( options ) ) {
74- options = { cwd : options } ;
75- }
70+ export async function downloadTgz ( url : string , opts : string | DownloadOptions ) : Promise < string | null > {
71+ const options = isString ( opts ) ? { path : opts } : opts ;
72+
7673 const gunzip = createGunzip ( ) ;
7774 const extractor = extractTar ( options ) ;
7875 gunzip . pipe ( extractor ) ;
@@ -83,10 +80,9 @@ export async function downloadTgz(url: string, options: string | DownloadOptions
8380 return sum ;
8481}
8582
86- export async function downloadZip ( url : string , options : string | DownloadOptions ) : Promise < string | null > {
87- if ( isString ( options ) ) {
88- options = { path : options } ;
89- }
83+ export async function downloadZip ( url : string , opts : string | DownloadOptions ) : Promise < string | null > {
84+ const options = isString ( opts ) ? { path : opts } : opts ;
85+
9086 const extractor = extractZip ( { path : options . path as string } ) ;
9187 const sum = await downloadToStream ( url , extractor , options . hashType ) ;
9288 if ( ! checkHashSum ( sum , options ) ) {
0 commit comments