mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-07 09:35:41 -05:00
* Merge from vscode a348d103d1256a06a2c9b3f9b406298a9fef6898 * Fixes and cleanup * Distro * Fix hygiene yarn * delete no yarn lock changes file * Fix hygiene * Fix layer check * Fix CI * Skip lib checks * Remove tests deleted in vs code * Fix tests * Distro * Fix tests and add removed extension point * Skip failing notebook tests for now * Disable broken tests and cleanup build folder * Update yarn.lock and fix smoke tests * Bump sqlite * fix contributed actions and file spacing * Fix user data path * Update yarn.locks Co-authored-by: ADS Merger <karlb@microsoft.com>
59 lines
2.0 KiB
TypeScript
59 lines
2.0 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
import * as assert from 'assert';
|
|
import * as fs from 'fs';
|
|
import * as platform from 'vs/base/common/platform';
|
|
import { enumeratePowerShellInstallations, getFirstAvailablePowerShellInstallation, IPowerShellExeDetails } from 'vs/base/node/powershell';
|
|
|
|
function checkPath(exePath: string) {
|
|
// Check to see if the path exists
|
|
let pathCheckResult = false;
|
|
try {
|
|
const stat = fs.statSync(exePath);
|
|
pathCheckResult = stat.isFile();
|
|
} catch {
|
|
// fs.exists throws on Windows with SymbolicLinks so we
|
|
// also use lstat to try and see if the file exists.
|
|
try {
|
|
pathCheckResult = fs.statSync(fs.readlinkSync(exePath)).isFile();
|
|
} catch {
|
|
|
|
}
|
|
}
|
|
|
|
assert.strictEqual(pathCheckResult, true);
|
|
}
|
|
|
|
if (platform.isWindows) {
|
|
suite('PowerShell finder', () => {
|
|
|
|
test('Can find first available PowerShell', async () => {
|
|
const pwshExe = await getFirstAvailablePowerShellInstallation();
|
|
const exePath = pwshExe?.exePath;
|
|
assert.notStrictEqual(exePath, null);
|
|
assert.notStrictEqual(pwshExe?.displayName, null);
|
|
|
|
checkPath(exePath!);
|
|
});
|
|
|
|
test('Can enumerate PowerShells', async () => {
|
|
const pwshs = new Array<IPowerShellExeDetails>();
|
|
for await (const p of enumeratePowerShellInstallations()) {
|
|
pwshs.push(p);
|
|
}
|
|
|
|
const powershellLog = 'Found these PowerShells:\n' + pwshs.map(p => `${p.displayName}: ${p.exePath}`).join('\n');
|
|
assert.strictEqual(pwshs.length >= 1, true, powershellLog);
|
|
|
|
for (const pwsh of pwshs) {
|
|
checkPath(pwsh.exePath);
|
|
}
|
|
|
|
// The last one should always be Windows PowerShell.
|
|
assert.strictEqual(pwshs[pwshs.length - 1].displayName, 'Windows PowerShell', powershellLog);
|
|
});
|
|
});
|
|
}
|