|
|
|
|
@@ -3,6 +3,7 @@
|
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
import '../base/file_system.dart';
|
|
|
|
|
import '../base/platform.dart';
|
|
|
|
|
import '../base/utils.dart';
|
|
|
|
|
import '../base/version.dart';
|
|
|
|
|
import '../convert.dart';
|
|
|
|
|
@@ -86,15 +87,18 @@ class VsCode {
|
|
|
|
|
|
|
|
|
|
Iterable<ValidationMessage> get validationMessages => _validationMessages;
|
|
|
|
|
|
|
|
|
|
static List<VsCode> allInstalled() {
|
|
|
|
|
if (globals.platform.isMacOS) {
|
|
|
|
|
return _installedMacOS();
|
|
|
|
|
static List<VsCode> allInstalled(
|
|
|
|
|
FileSystem fileSystem,
|
|
|
|
|
Platform platform,
|
|
|
|
|
) {
|
|
|
|
|
if (platform.isMacOS) {
|
|
|
|
|
return _installedMacOS(fileSystem);
|
|
|
|
|
}
|
|
|
|
|
if (globals.platform.isWindows) {
|
|
|
|
|
return _installedWindows();
|
|
|
|
|
if (platform.isWindows) {
|
|
|
|
|
return _installedWindows(fileSystem, platform);
|
|
|
|
|
}
|
|
|
|
|
if (globals.platform.isLinux) {
|
|
|
|
|
return _installedLinux();
|
|
|
|
|
if (platform.isLinux) {
|
|
|
|
|
return _installedLinux(fileSystem);
|
|
|
|
|
}
|
|
|
|
|
// VS Code isn't supported on the other platforms.
|
|
|
|
|
return <VsCode>[];
|
|
|
|
|
@@ -108,14 +112,14 @@ class VsCode {
|
|
|
|
|
// macOS Extensions:
|
|
|
|
|
// $HOME/.vscode/extensions
|
|
|
|
|
// $HOME/.vscode-insiders/extensions
|
|
|
|
|
static List<VsCode> _installedMacOS() {
|
|
|
|
|
static List<VsCode> _installedMacOS(FileSystem fileSystem) {
|
|
|
|
|
return _findInstalled(<_VsCodeInstallLocation>[
|
|
|
|
|
_VsCodeInstallLocation(
|
|
|
|
|
globals.fs.path.join('/Applications', 'Visual Studio Code.app', 'Contents'),
|
|
|
|
|
fileSystem.path.join('/Applications', 'Visual Studio Code.app', 'Contents'),
|
|
|
|
|
'.vscode',
|
|
|
|
|
),
|
|
|
|
|
_VsCodeInstallLocation(
|
|
|
|
|
globals.fs.path.join(
|
|
|
|
|
fileSystem.path.join(
|
|
|
|
|
globals.fsUtils.homeDirPath,
|
|
|
|
|
'Applications',
|
|
|
|
|
'Visual Studio Code.app',
|
|
|
|
|
@@ -124,12 +128,12 @@ class VsCode {
|
|
|
|
|
'.vscode',
|
|
|
|
|
),
|
|
|
|
|
_VsCodeInstallLocation(
|
|
|
|
|
globals.fs.path.join('/Applications', 'Visual Studio Code - Insiders.app', 'Contents'),
|
|
|
|
|
fileSystem.path.join('/Applications', 'Visual Studio Code - Insiders.app', 'Contents'),
|
|
|
|
|
'.vscode-insiders',
|
|
|
|
|
isInsiders: true,
|
|
|
|
|
),
|
|
|
|
|
_VsCodeInstallLocation(
|
|
|
|
|
globals.fs.path.join(
|
|
|
|
|
fileSystem.path.join(
|
|
|
|
|
globals.fsUtils.homeDirPath,
|
|
|
|
|
'Applications',
|
|
|
|
|
'Visual Studio Code - Insiders.app',
|
|
|
|
|
@@ -138,7 +142,7 @@ class VsCode {
|
|
|
|
|
'.vscode-insiders',
|
|
|
|
|
isInsiders: true,
|
|
|
|
|
),
|
|
|
|
|
]);
|
|
|
|
|
], fileSystem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Windows:
|
|
|
|
|
@@ -153,51 +157,56 @@ class VsCode {
|
|
|
|
|
// Windows Extensions:
|
|
|
|
|
// $HOME/.vscode/extensions
|
|
|
|
|
// $HOME/.vscode-insiders/extensions
|
|
|
|
|
static List<VsCode> _installedWindows() {
|
|
|
|
|
final String progFiles86 = globals.platform.environment['programfiles(x86)'];
|
|
|
|
|
final String progFiles = globals.platform.environment['programfiles'];
|
|
|
|
|
final String localAppData = globals.platform.environment['localappdata'];
|
|
|
|
|
static List<VsCode> _installedWindows(
|
|
|
|
|
FileSystem fileSystem,
|
|
|
|
|
Platform platform,
|
|
|
|
|
) {
|
|
|
|
|
final String progFiles86 = platform.environment['programfiles(x86)'];
|
|
|
|
|
final String progFiles = platform.environment['programfiles'];
|
|
|
|
|
final String localAppData = platform.environment['localappdata'];
|
|
|
|
|
|
|
|
|
|
final List<_VsCodeInstallLocation> searchLocations =
|
|
|
|
|
<_VsCodeInstallLocation>[];
|
|
|
|
|
|
|
|
|
|
if (localAppData != null) {
|
|
|
|
|
searchLocations.add(_VsCodeInstallLocation(
|
|
|
|
|
globals.fs.path.join(localAppData, r'Programs\Microsoft VS Code'),
|
|
|
|
|
'.vscode',
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
searchLocations.add(_VsCodeInstallLocation(
|
|
|
|
|
globals.fs.path.join(progFiles86, 'Microsoft VS Code'),
|
|
|
|
|
'.vscode',
|
|
|
|
|
edition: '32-bit edition',
|
|
|
|
|
));
|
|
|
|
|
searchLocations.add(_VsCodeInstallLocation(
|
|
|
|
|
globals.fs.path.join(progFiles, 'Microsoft VS Code'),
|
|
|
|
|
'.vscode',
|
|
|
|
|
edition: '64-bit edition',
|
|
|
|
|
));
|
|
|
|
|
if (localAppData != null) {
|
|
|
|
|
searchLocations.add(_VsCodeInstallLocation(
|
|
|
|
|
globals.fs.path.join(localAppData, r'Programs\Microsoft VS Code Insiders'),
|
|
|
|
|
'.vscode-insiders',
|
|
|
|
|
isInsiders: true,
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
searchLocations.add(_VsCodeInstallLocation(
|
|
|
|
|
globals.fs.path.join(progFiles86, 'Microsoft VS Code Insiders'),
|
|
|
|
|
'.vscode-insiders',
|
|
|
|
|
edition: '32-bit edition',
|
|
|
|
|
isInsiders: true,
|
|
|
|
|
));
|
|
|
|
|
searchLocations.add(_VsCodeInstallLocation(
|
|
|
|
|
globals.fs.path.join(progFiles, 'Microsoft VS Code Insiders'),
|
|
|
|
|
'.vscode-insiders',
|
|
|
|
|
edition: '64-bit edition',
|
|
|
|
|
isInsiders: true,
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
return _findInstalled(searchLocations);
|
|
|
|
|
final List<_VsCodeInstallLocation> searchLocations = <_VsCodeInstallLocation>[
|
|
|
|
|
if (localAppData != null)
|
|
|
|
|
_VsCodeInstallLocation(
|
|
|
|
|
fileSystem.path.join(localAppData, r'Programs\Microsoft VS Code'),
|
|
|
|
|
'.vscode',
|
|
|
|
|
),
|
|
|
|
|
if (progFiles86 != null)
|
|
|
|
|
...<_VsCodeInstallLocation>[
|
|
|
|
|
_VsCodeInstallLocation(
|
|
|
|
|
fileSystem.path.join(progFiles86, 'Microsoft VS Code'),
|
|
|
|
|
'.vscode',
|
|
|
|
|
edition: '32-bit edition',
|
|
|
|
|
),
|
|
|
|
|
_VsCodeInstallLocation(
|
|
|
|
|
fileSystem.path.join(progFiles86, 'Microsoft VS Code Insiders'),
|
|
|
|
|
'.vscode-insiders',
|
|
|
|
|
edition: '32-bit edition',
|
|
|
|
|
isInsiders: true,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
if (progFiles != null)
|
|
|
|
|
...<_VsCodeInstallLocation>[
|
|
|
|
|
_VsCodeInstallLocation(
|
|
|
|
|
fileSystem.path.join(progFiles, 'Microsoft VS Code'),
|
|
|
|
|
'.vscode',
|
|
|
|
|
edition: '64-bit edition',
|
|
|
|
|
),
|
|
|
|
|
_VsCodeInstallLocation(
|
|
|
|
|
fileSystem.path.join(progFiles, 'Microsoft VS Code Insiders'),
|
|
|
|
|
'.vscode-insiders',
|
|
|
|
|
edition: '64-bit edition',
|
|
|
|
|
isInsiders: true,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
if (localAppData != null)
|
|
|
|
|
_VsCodeInstallLocation(
|
|
|
|
|
fileSystem.path.join(localAppData, r'Programs\Microsoft VS Code Insiders'),
|
|
|
|
|
'.vscode-insiders',
|
|
|
|
|
isInsiders: true,
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
return _findInstalled(searchLocations, fileSystem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Linux:
|
|
|
|
|
@@ -206,7 +215,7 @@ class VsCode {
|
|
|
|
|
// Linux Extensions:
|
|
|
|
|
// $HOME/.vscode/extensions
|
|
|
|
|
// $HOME/.vscode-insiders/extensions
|
|
|
|
|
static List<VsCode> _installedLinux() {
|
|
|
|
|
static List<VsCode> _installedLinux(FileSystem fileSystem) {
|
|
|
|
|
return _findInstalled(<_VsCodeInstallLocation>[
|
|
|
|
|
const _VsCodeInstallLocation('/usr/share/code', '.vscode'),
|
|
|
|
|
const _VsCodeInstallLocation(
|
|
|
|
|
@@ -214,10 +223,13 @@ class VsCode {
|
|
|
|
|
'.vscode-insiders',
|
|
|
|
|
isInsiders: true,
|
|
|
|
|
),
|
|
|
|
|
]);
|
|
|
|
|
], fileSystem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static List<VsCode> _findInstalled(List<_VsCodeInstallLocation> allLocations) {
|
|
|
|
|
static List<VsCode> _findInstalled(
|
|
|
|
|
List<_VsCodeInstallLocation> allLocations,
|
|
|
|
|
FileSystem fileSystem,
|
|
|
|
|
) {
|
|
|
|
|
final Iterable<_VsCodeInstallLocation> searchLocations =
|
|
|
|
|
_includeInsiders
|
|
|
|
|
? allLocations
|
|
|
|
|
@@ -226,8 +238,8 @@ class VsCode {
|
|
|
|
|
final List<VsCode> results = <VsCode>[];
|
|
|
|
|
|
|
|
|
|
for (final _VsCodeInstallLocation searchLocation in searchLocations) {
|
|
|
|
|
if (globals.fs.isDirectorySync(searchLocation.installPath)) {
|
|
|
|
|
final String extensionDirectory = globals.fs.path.join(
|
|
|
|
|
if (fileSystem.isDirectorySync(searchLocation.installPath)) {
|
|
|
|
|
final String extensionDirectory = fileSystem.path.join(
|
|
|
|
|
globals.fsUtils.homeDirPath,
|
|
|
|
|
searchLocation.extensionsFolder,
|
|
|
|
|
'extensions',
|
|
|
|
|
|