Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
octref committed Jun 26, 2019
1 parent 5eddf87 commit 568b986
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
9 changes: 8 additions & 1 deletion lib/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,20 @@ async function isValidVersion(version: string) {
return version === 'insiders' || validVersions.indexOf(version) !== -1;
}

/**
* Adapted from https://github.com/microsoft/TypeScript/issues/29729
* Since `string | 'foo'` doesn't offer auto completion
*/
type StringLiteralUnion<T extends U, U = string> = T | (U & {});
export type DownloadVersion = StringLiteralUnion<'insiders'>;

/**
* Download a copy of VS Code archive to `.vscode-test`.
*
* @param version The version of VS Code to download such as '1.32.0'. You can also use
* 'insiders' for downloading latest Insiders.
*/
async function downloadVSCodeArchive(version: string): Promise<string> {
async function downloadVSCodeArchive(version: DownloadVersion): Promise<string> {
if (!fs.existsSync(vscodeTestDir)) {
fs.mkdirSync(vscodeTestDir);
}
Expand Down
12 changes: 6 additions & 6 deletions lib/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import * as cp from 'child_process';
import { downloadAndUnzipVSCode } from './download';
import { downloadAndUnzipVSCode, DownloadVersion } from './download';

export interface TestOptions {
/**
Expand All @@ -22,7 +22,7 @@ export interface TestOptions {
*
* Defaults to latest stable version.
*/
version?: string;
version?: DownloadVersion;

/**
* Absolute path to the extension root. Passed to `--extensionDevelopmentPath`.
Expand Down Expand Up @@ -98,19 +98,19 @@ async function innerRunTests(
const fullEnv = Object.assign({}, process.env, testRunnerEnv);
const cmd = cp.spawn(executable, args, { env: fullEnv });

cmd.stdout.on('data', function(data) {
cmd.stdout.on('data', function (data) {
console.log(data.toString());
});

cmd.stderr.on('data', function(data) {
cmd.stderr.on('data', function (data) {
console.error(data.toString());
});

cmd.on('error', function(data) {
cmd.on('error', function (data) {
console.log('Test error: ' + data.toString());
});

cmd.on('close', function(code) {
cmd.on('close', function (code) {
console.log(`Exit code: ${code}`);

if (code !== 0) {
Expand Down

0 comments on commit 568b986

Please sign in to comment.