import { File } from 'decompress' ; import * as glob from 'glob' ; import * as gulp from 'gulp' ; import decompress = require ( 'gulp-decompress' ) ; import download = require ( 'gulp-download' ) ; import * as os from 'os' ; import * as path from 'path' ; import { Stream } from 'stream' ; export function gulp_installRestClient ( ) { const version = '0.21.3' ; const extensionPath = path . join ( os . homedir ( ) , `.vscode/extensions/humao.rest-client-${ version }` ) ; const existingExtensions = glob . sync ( extensionPath . replace ( version , '*' ) ) ; if ( existingExtensions . length === 0 ) { console . log ( "installing rest-client extension." ) ; return download ( `http://humao.gallery.vsassets.io/_apis/public/gallery/publisher/humao/extension/rest-client/${ version }/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage` ) . pipe ( decompress ( { filter : ( file ) : boolean => file . path . startsWith ( 'extension/' ) , map : ( file ) : File => { file . path = file . path . slice ( 10 ) ; return file ; } } ) ) . pipe ( gulp . dest ( extensionPath ) ) ; } else { console . log ( "rest-client extension already installed." ) ; return Promise . resolve ( ) ; } }