@@ -13,8 +13,9 @@ import * as tmp from 'tmp';
1313import { parse } from 'url' ;
1414import { SupportedPlatform , getSupportedPlatform } from './utils' ;
1515import { getProxyAgent } from './proxy' ;
16+ import { OutputChannel } from 'vscode' ;
1617
17- const Decompress = require ( 'decompress' ) ;
18+ const decompress = require ( 'decompress' ) ;
1819
1920const BaseDownloadUrl = 'https://vscodeoscon.blob.core.windows.net/ext' ;
2021const DefaultInstallLocation = path . join ( __dirname , '../.omnisharp' ) ;
@@ -73,14 +74,14 @@ function download(urlString: string): Promise<stream.Readable> {
7374 } ) ;
7475}
7576
76- export function downloadOmnisharp ( ) : Promise < boolean > {
77+ export function downloadOmnisharp ( output : OutputChannel ) : Promise < boolean > {
7778 return new Promise < boolean > ( ( resolve , reject ) => {
78- console . log ( `[OmniSharp]: Installing to ${ DefaultInstallLocation } ` ) ;
79+ output . appendLine ( `[INFO] Installing to ${ DefaultInstallLocation } ` ) ;
7980
8081 const assetName = getOmnisharpAssetName ( ) ;
8182 const urlString = `${ BaseDownloadUrl } /${ assetName } ` ;
8283
83- console . log ( `[OmniSharp ] Attempting to download ${ assetName } ...` ) ;
84+ output . appendLine ( `[INFO ] Attempting to download ${ assetName } ...` ) ;
8485
8586 return download ( urlString )
8687 . then ( inStream => {
@@ -89,7 +90,7 @@ export function downloadOmnisharp(): Promise<boolean> {
8990 return reject ( err ) ;
9091 }
9192
92- console . log ( `[OmniSharp ] Downloading to ${ tmpPath } ...` ) ;
93+ output . appendLine ( `[INFO ] Downloading to ${ tmpPath } ...` ) ;
9394
9495 const outStream = fs . createWriteStream ( null , { fd : fd } ) ;
9596
@@ -99,30 +100,18 @@ export function downloadOmnisharp(): Promise<boolean> {
99100 outStream . once ( 'finish' , ( ) => {
100101 // At this point, the asset has finished downloading.
101102
102- console . log ( `[OmniSharp] Download complete!` ) ;
103+ output . appendLine ( `[INFO] Download complete!` ) ;
104+ output . appendLine ( `[INFO] Decompressing...` ) ;
103105
104- let decompress = new Decompress ( )
105- . src ( tmpPath )
106- . dest ( DefaultInstallLocation ) ;
107-
108- if ( path . extname ( assetName ) . toLowerCase ( ) === '.zip' ) {
109- decompress = decompress . use ( Decompress . zip ( ) ) ;
110- console . log ( `[OmniSharp] Unzipping...` ) ;
111- }
112- else {
113- decompress = decompress . use ( Decompress . targz ( ) ) ;
114- console . log ( `[OmniSharp] Untaring...` ) ;
115- }
116-
117- decompress . run ( ( err , files ) => {
118- if ( err ) {
106+ return decompress ( tmpPath , DefaultInstallLocation )
107+ . then ( files => {
108+ output . appendLine ( `[INFO] Done! ${ files . length } files unpacked.` )
109+ return resolve ( true ) ;
110+ } )
111+ . error ( err => {
112+ output . appendLine ( `[ERROR] ${ err } ` ) ;
119113 return reject ( err ) ;
120- }
121-
122- console . log ( `[OmniSharp] Done! ${ files . length } files unpacked.` )
123-
124- return resolve ( true ) ;
125- } ) ;
114+ } ) ;
126115 } ) ;
127116
128117 inStream . pipe ( outStream ) ;
0 commit comments