Skip to content

Commit 99ce290

Browse files
authored
Use vsce API instead CLI (#715)
Signed-off-by: Marian Lorinc <mlorinc@redhat.com>
1 parent 717244a commit 99ce290

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

src/extester.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class ExTester {
7171
target = await this.code.downloadExtension(vsixFile);
7272
}
7373
} else {
74-
this.code.packageExtension(useYarn);
74+
await this.code.packageExtension(useYarn);
7575
}
7676
return this.code.installExtension(target);
7777
}

src/util/codeUtil.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
'use strict';
22

3+
import * as child_process from 'child_process';
34
import * as fs from 'fs-extra';
45
import * as path from 'path';
5-
import * as child_process from 'child_process';
6+
import * as vsce from '@vscode/vsce';
67
import { VSRunner } from "../suite/runner";
78
import { Unpack } from "./unpack";
89
import { 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

Comments
 (0)