Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* fix(OSS):

enums.ts
----
Allow for setting os type with less code

environmentPath.ts
----
Find code folder and extensions folder more efficiently
Get OS type more efficiently

settings.ts
----
Ignore all state files

sync.ts
----
Adapt for changes in pluginService

pluginService.ts
----
Use vscode command to install extensions
Clean up code and simplify names

* Install extensions in order

* Comment legacy code instead of deleting it

* Fix extension install

* Fix issue with extensions always being deleted

* Get code path more efficiently

* Make sure to escape spaces in cli path

* Fix issues with portable builds

* Support Windows and certain editions

* Improve method for finding extension folder

* Start using API for installation

* Prepare for new API command

* Get ready for new API command

* Fix issue with installation

* Commit requested changes
  • Loading branch information
auxves authored and shanalikhan committed Jun 24, 2019
1 parent f10edf6 commit 9b7ce05
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 234 deletions.
6 changes: 3 additions & 3 deletions src/enums.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export enum OsType {
Windows = 1,
Linux,
Mac
Windows = "win32",
Linux = "linux",
Mac = "darwin"
}

export enum SettingType {
Expand Down
54 changes: 43 additions & 11 deletions src/environmentPath.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"use strict";

import * as fs from "fs-extra";
import * as os from "os";
import * as path from "path";
import { normalize, resolve } from "path";
import * as vscode from "vscode";
import { OsType } from "./enums";

Expand All @@ -28,14 +26,17 @@ export class Environment {
);
}

public isInsiders: boolean = false;
public isOss: boolean = false;
// public isInsiders: boolean = false;
// public isOss: boolean = false;
// public isCoderCom: boolean = false;
// public homeDir: string | null = null;

public isPortable: boolean = false;
public isCoderCom: boolean = false;
public homeDir: string | null = null;
public USER_FOLDER: string = null;

public ExtensionFolder: string = null;
public CODE_BIN: string;

public EXTENSION_FOLDER: string = null;
public PATH: string = null;
public OsType: OsType = null;

Expand Down Expand Up @@ -64,8 +65,37 @@ export class Environment {
public FOLDER_SNIPPETS: string = null;

constructor(private context: vscode.ExtensionContext) {
this.context.globalState.update("_", undefined); // Make sure the global state folder exists. This is needed for using this.context.globalStoragePath to access user folder

this.isPortable = !!process.env.VSCODE_PORTABLE;

this.OsType = process.platform as OsType;
if (!this.isPortable) {
this.PATH = resolve(this.context.globalStoragePath, "../../..").concat(
normalize("/")
);
this.USER_FOLDER = resolve(this.PATH, "User").concat(normalize("/"));
this.EXTENSION_FOLDER = resolve(
vscode.extensions.all.filter(
extension => !extension.packageJSON.isBuiltin
)[0].extensionPath,
".."
).concat(normalize("/")); // Gets first non-builtin extension's path
}

if (this.isPortable) {
this.PATH = process.env.VSCODE_PORTABLE;
this.USER_FOLDER = resolve(this.PATH, "user-data/User").concat(
normalize("/")
);
this.EXTENSION_FOLDER = resolve(this.PATH, "extensions").concat(
normalize("/")
);
}

/* Start Legacy Code
this.isInsiders = /insiders/.test(this.context.asAbsolutePath(""));
this.isPortable = process.env.VSCODE_PORTABLE ? true : false;
this.isOss = /\boss\b/.test(this.context.asAbsolutePath(""));
this.isCoderCom =
vscode.extensions.getExtension("coder.coder") !== undefined;
Expand All @@ -77,8 +107,8 @@ export class Environment {
this.homeDir = isXdg
? process.env.XDG_DATA_HOME
: process.env[process.platform === "win32" ? "USERPROFILE" : "HOME"];
const configSuffix = `${isXdg || this.isCoderCom ? "" : "."}vscode${
this.isInsiders ? "-insiders" : this.isOss ? "-oss" : ""
const configSuffix = `; $; {isXdg || this.isCoderCom ? "" : "."; }vscode$; {
this.isInsiders ? "-insiders" : this.isOss ? "-oss" : "";
}`;
if (!this.isPortable) {
Expand Down Expand Up @@ -148,6 +178,8 @@ export class Environment {
this.ExtensionFolder = this.PATH.concat("/extensions/");
}
End Legacy Code */

this.FILE_EXTENSION = this.USER_FOLDER.concat(this.FILE_EXTENSION_NAME);
this.FILE_SETTING = this.USER_FOLDER.concat(this.FILE_SETTING_NAME);
this.FILE_LAUNCH = this.USER_FOLDER.concat(this.FILE_LAUNCH_NAME);
Expand Down
Loading

0 comments on commit 9b7ce05

Please sign in to comment.