Add setting for default dacpac save location (#13194)

* add setting for default save location

* lowercase

* addressing comments
This commit is contained in:
Kim Santiago
2020-11-11 17:20:58 -08:00
committed by GitHub
parent 865d49c2fb
commit 850422164c
5 changed files with 55 additions and 4 deletions

View File

@@ -0,0 +1,7 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export const dacFxConfigurationKey = 'dacFx';
export const dacFxSaveLocationKey = 'defaultSaveLocation';

View File

@@ -0,0 +1,30 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import * as fs from 'fs';
import * as os from 'os';
import * as constants from '../common/constants';
/**
* Returns the default location to save a dacpac or bacpac
*/
export function defaultSaveLocation(): string {
return dacFxSaveLocationSettingIsValid() ? dacFxSaveLocationSetting() : os.homedir();
}
/**
* Returns the workspace setting on the default location to save dacpacs and bacpacs
*/
function dacFxSaveLocationSetting(): string {
return vscode.workspace.getConfiguration(constants.dacFxConfigurationKey)[constants.dacFxSaveLocationKey];
}
/**
* Returns if the default save location for dacpacs and bacpacs setting exists and is a valid path
*/
function dacFxSaveLocationSettingIsValid(): boolean {
return dacFxSaveLocationSetting() && dacFxSaveLocationSetting().trim() !== '' && fs.existsSync(dacFxSaveLocationSetting());
}