mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 17:22:45 -05:00
Get tools service install location from extensions (#16796)
* Get STS install location from extensions * Update error
This commit is contained in:
@@ -5,10 +5,9 @@
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as path from 'path';
|
||||
import * as os from 'os';
|
||||
import { promises as fs } from 'fs';
|
||||
import * as utils from '../common/utils';
|
||||
import { sqlToolsServiceNotFound } from '../common/constants';
|
||||
import { errorFindingBuildFilesLocation } from '../common/constants';
|
||||
import * as mssql from '../../../mssql/src/mssql';
|
||||
import * as vscodeMssql from 'vscode-mssql';
|
||||
import * as sqldbproj from 'sqldbproj';
|
||||
@@ -66,41 +65,15 @@ export class BuildHelper {
|
||||
* @returns
|
||||
*/
|
||||
private async getBuildDirPathFromMssqlTools(): Promise<string> {
|
||||
let mssqlConfigDir = '';
|
||||
if (utils.getAzdataApi()) {
|
||||
mssqlConfigDir = vscode.extensions.getExtension(mssql.extension.name)?.extensionPath ?? '';
|
||||
} else {
|
||||
// VS Code MSSQL extension has its tools service config in a slightly different spot
|
||||
mssqlConfigDir = path.join(vscode.extensions.getExtension(vscodeMssql.extension.name)?.extensionPath ?? '', 'out', 'src');
|
||||
}
|
||||
|
||||
if (await utils.exists(path.join(mssqlConfigDir, 'config.json'))) {
|
||||
const rawConfig = await fs.readFile(path.join(mssqlConfigDir, 'config.json'));
|
||||
const config = JSON.parse(rawConfig.toString());
|
||||
let installDir = '';
|
||||
try {
|
||||
if (utils.getAzdataApi()) {
|
||||
installDir = config.installDirectory?.replace('{#version#}', config.version).replace('{#platform#}', this.getPlatform());
|
||||
return (vscode.extensions.getExtension(mssql.extension.name)?.exports as mssql.IExtension).sqlToolsServicePath;
|
||||
} else {
|
||||
// VS Code MSSQL extension has a slightly different format for its config.json
|
||||
installDir = config.service?.installDir?.replace('{#version#}', config.service.version).replace('{#platform#}', this.getPlatform());
|
||||
if (installDir) {
|
||||
// The path to the install location is relative to one directory above where the config is so account for that here
|
||||
installDir = path.join('..', installDir);
|
||||
}
|
||||
}
|
||||
|
||||
if (installDir) {
|
||||
return path.join(mssqlConfigDir, installDir);
|
||||
return (vscode.extensions.getExtension(vscodeMssql.extension.name)?.exports as vscodeMssql.IExtension).sqlToolsServicePath;
|
||||
}
|
||||
} catch (err) {
|
||||
throw new Error(errorFindingBuildFilesLocation(err));
|
||||
}
|
||||
throw new Error(sqlToolsServiceNotFound(mssqlConfigDir));
|
||||
}
|
||||
|
||||
private getPlatform(): string {
|
||||
return os.platform() === 'win32' ? 'Windows' :
|
||||
os.platform() === 'darwin' ? 'OSX' :
|
||||
os.platform() === 'linux' ? 'Linux' :
|
||||
'';
|
||||
}
|
||||
|
||||
public get extensionBuildDirPath(): string {
|
||||
|
||||
Reference in New Issue
Block a user