11'use strict' ;
22
3+ import * as child_process from 'child_process' ;
34import * as fs from 'fs-extra' ;
45import * as path from 'path' ;
5- import * as child_process from 'child_process ' ;
6+ import * as vsce from '@vscode/vsce ' ;
67import { VSRunner } from "../suite/runner" ;
78import { Unpack } from "./unpack" ;
89import { logging } from "selenium-webdriver" ;
@@ -94,7 +95,7 @@ export class CodeUtil {
9495 await this . checkCodeVersion ( version ) ;
9596
9697 const literalVersion = version === 'latest' ? this . availableVersions [ 0 ] : version ;
97- if ( this . releaseType == ReleaseQuality . Stable && literalVersion !== this . availableVersions [ 0 ] ) {
98+ if ( this . releaseType == ReleaseQuality . Stable && literalVersion !== this . availableVersions [ 0 ] ) {
9899 console . log ( `
99100 WARNING: You are using the outdated VSCode version '${ literalVersion } '. The latest stable version is '${ this . availableVersions [ 0 ] } '.
100101 ` ) ;
@@ -107,11 +108,11 @@ export class CodeUtil {
107108 const url = [ 'https://update.code.visualstudio.com' , version , this . downloadPlatform , this . releaseType ] . join ( '/' ) ;
108109 const isTarGz = this . downloadPlatform . indexOf ( 'linux' ) > - 1 ;
109110 const fileName = `${ path . basename ( url ) } .${ isTarGz ? 'tar.gz' : 'zip' } ` ;
110-
111+
111112 console . log ( `Downloading VS Code from: ${ url } ` ) ;
112113 await Download . getFile ( url , path . join ( this . downloadFolder , fileName ) , true ) ;
113114 console . log ( `Downloaded VS Code into ${ path . join ( this . downloadFolder , fileName ) } ` ) ;
114-
115+
115116 console . log ( `Unpacking VS Code into ${ this . downloadFolder } ` ) ;
116117 const target = await fs . mkdtemp ( 'vscode' ) ;
117118 await Unpack . unpack ( path . join ( this . downloadFolder , fileName ) , target ) ;
@@ -196,14 +197,10 @@ export class CodeUtil {
196197 * Package extension into a vsix file
197198 * @param useYarn false to use npm as packaging system, true to use yarn instead
198199 */
199- packageExtension ( useYarn ?: boolean ) : void {
200- let vscePath = path . join ( __dirname , '..' , '..' , 'node_modules' , '.bin' , 'vsce' ) ;
201- if ( ! fs . existsSync ( vscePath ) ) {
202- vscePath = path . join ( 'node_modules' , '.bin' , 'vsce' ) ;
203- }
204- const cliCall = `${ vscePath } package ${ useYarn ? '--yarn' : '--no-yarn' } ` ;
205-
206- child_process . execSync ( cliCall , { stdio : 'inherit' } ) ;
200+ async packageExtension ( useYarn ?: boolean ) : Promise < void > {
201+ await vsce . createVSIX ( {
202+ useYarn
203+ } ) ;
207204 }
208205
209206 /**
@@ -303,7 +300,7 @@ export class CodeUtil {
303300 await this . getExistingCodeVersion ( ) ;
304301 } catch ( err ) {
305302 console . log ( 'ERROR: Cannot find a local copy of VS Code in offline mode, exiting.' ) ;
306- throw ( err ) ;
303+ throw ( err ) ;
307304 }
308305 return this . getChromiumVersionOffline ( ) ;
309306 }
0 commit comments