mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from master
This commit is contained in:
@@ -3,12 +3,13 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { Workbench } from './areas/workbench/workbench';
|
||||
import * as cp from 'child_process';
|
||||
import { Code, spawn, SpawnOptions } from './vscode/code';
|
||||
import { Logger } from './logger';
|
||||
|
||||
export enum Quality {
|
||||
export const enum Quality {
|
||||
Dev,
|
||||
Insiders,
|
||||
Stable
|
||||
@@ -17,8 +18,8 @@ export enum Quality {
|
||||
export interface ApplicationOptions extends SpawnOptions {
|
||||
quality: Quality;
|
||||
workspacePath: string;
|
||||
workspaceFilePath: string;
|
||||
waitTime: number;
|
||||
screenshotsPath: string | null;
|
||||
}
|
||||
|
||||
export class Application {
|
||||
@@ -26,7 +27,9 @@ export class Application {
|
||||
private _code: Code | undefined;
|
||||
private _workbench: Workbench;
|
||||
|
||||
constructor(private options: ApplicationOptions) { }
|
||||
constructor(private options: ApplicationOptions) {
|
||||
this._workspacePathOrFolder = options.workspacePath;
|
||||
}
|
||||
|
||||
get quality(): Quality {
|
||||
return this.options.quality;
|
||||
@@ -44,8 +47,9 @@ export class Application {
|
||||
return this.options.logger;
|
||||
}
|
||||
|
||||
get workspacePath(): string {
|
||||
return this.options.workspacePath;
|
||||
private _workspacePathOrFolder: string;
|
||||
get workspacePathOrFolder(): string {
|
||||
return this._workspacePathOrFolder;
|
||||
}
|
||||
|
||||
get extensionsPath(): string {
|
||||
@@ -56,10 +60,6 @@ export class Application {
|
||||
return this.options.userDataDir;
|
||||
}
|
||||
|
||||
get workspaceFilePath(): string {
|
||||
return this.options.workspaceFilePath;
|
||||
}
|
||||
|
||||
async start(): Promise<any> {
|
||||
await this._start();
|
||||
//{{SQL CARBON EDIT}}
|
||||
@@ -79,9 +79,9 @@ export class Application {
|
||||
await this._start(options.workspaceOrFolder, options.extraArgs);
|
||||
}
|
||||
|
||||
private async _start(workspaceOrFolder = this.options.workspacePath, extraArgs: string[] = []): Promise<any> {
|
||||
cp.execSync('git checkout .', { cwd: this.options.workspacePath });
|
||||
await this.startApplication(workspaceOrFolder, extraArgs);
|
||||
private async _start(workspaceOrFolder = this.workspacePathOrFolder, extraArgs: string[] = []): Promise<any> {
|
||||
this._workspacePathOrFolder = workspaceOrFolder;
|
||||
await this.startApplication(extraArgs);
|
||||
await this.checkWindowReady();
|
||||
}
|
||||
|
||||
@@ -101,14 +101,22 @@ export class Application {
|
||||
}
|
||||
}
|
||||
|
||||
async capturePage(): Promise<string> {
|
||||
return this.code.capturePage();
|
||||
async captureScreenshot(name: string): Promise<void> {
|
||||
if (this.options.screenshotsPath) {
|
||||
const raw = await this.code.capturePage();
|
||||
const buffer = Buffer.from(raw, 'base64');
|
||||
const screenshotPath = path.join(this.options.screenshotsPath, `${name}.png`);
|
||||
if (this.options.log) {
|
||||
this.logger.log('*** Screenshot recorded:', screenshotPath);
|
||||
}
|
||||
fs.writeFileSync(screenshotPath, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
private async startApplication(workspaceOrFolder: string, extraArgs: string[] = []): Promise<any> {
|
||||
private async startApplication(extraArgs: string[] = []): Promise<any> {
|
||||
this._code = await spawn({
|
||||
codePath: this.options.codePath,
|
||||
workspacePath: workspaceOrFolder,
|
||||
workspacePath: this.workspacePathOrFolder,
|
||||
userDataDir: this.options.userDataDir,
|
||||
extensionsPath: this.options.extensionsPath,
|
||||
logger: this.options.logger,
|
||||
|
||||
Reference in New Issue
Block a user