Permalink
Browse files

Apply bundledModulesPath setting only when in development mode

This change improves our handling of the bundledModulesPath setting by
only making it active when VS Code is in development mode (either running
in the debugger or with the --extensionDevelopmentPath setting).  This
enables extension developers to use their installed PowerShell extension's
bundled modules in normal circumstances, only switching to the
bundledModulesPath when they are running a development build.

This code also sets the default bundledModulesPath to a
peer (co-located) PowerShellEditorServices folder since most developers
will probably clone the two repos into the same folder.  One would only
need to set their bundledModulesPath if their PSES repo folder was in an
unconventional path.

The bundledModulesPath setting will likely be renamed to something more
appropriate in the next update.
  • Loading branch information...
daviwil committed Jan 23, 2017
1 parent 3d9319b commit 5f9cfd6c664caf29c432f9948f5113fe0aef515a
Showing with 25 additions and 5 deletions.
  1. +0 −1 package.json
  2. +24 −3 src/session.ts
  3. +1 −1 src/settings.ts
View
@@ -323,7 +323,6 @@
},
"powershell.developer.bundledModulesPath": {
"type": "string",
"default": "../modules/",
"description": "Specifies the path to the folder containing modules that are bundled with the PowerShell extension (i.e. PowerShell Editor Services, PowerShell Script Analyzer, Plaster)"
},
"powershell.developer.editorServicesLogLevel": {
View
@@ -72,6 +72,12 @@ export class SessionManager {
private languageServerClient: LanguageClient = undefined;
private sessionSettings: Settings.ISettings = undefined;
// When in development mode, VS Code's session ID is a fake
// value of "someValue.machineId". Use that to detect dev
// mode for now until Microsoft/vscode#10272 gets implemented.
private readonly inDevelopmentMode =
vscode.env.sessionId === "someValue.sessionId";
constructor(
private requiredEditorServicesVersion: string,
private log: Logger,
@@ -100,9 +106,24 @@ export class SessionManager {
if (this.sessionConfiguration.type === SessionType.UsePath ||
this.sessionConfiguration.type === SessionType.UseBuiltIn) {
var bundledModulesPath = this.sessionSettings.developer.bundledModulesPath;
if (!path.isAbsolute(bundledModulesPath)) {
bundledModulesPath = path.resolve(__dirname, bundledModulesPath);
var bundledModulesPath = path.resolve(__dirname, "../modules");
if (this.inDevelopmentMode) {
var devBundledModulesPath =
// this.sessionSettings.developer.bundledModulesPath ||
path.resolve(
__dirname,
this.sessionSettings.developer.bundledModulesPath ||
"../../PowerShellEditorServices/module");
// Make sure the module's bin path exists
if (fs.existsSync(path.join(devBundledModulesPath, "PowerShellEditorServices/bin"))) {
bundledModulesPath = devBundledModulesPath;
}
else {
this.log.write(
`\nWARNING: In development mode but PowerShellEditorServices dev module path cannot be found (or has not been built yet): ${devBundledModulesPath}\n`);
}
}
var startArgs =
View
@@ -42,7 +42,7 @@ export function load(myPluginId: string): ISettings {
let defaultDeveloperSettings: IDeveloperSettings = {
powerShellExePath: undefined,
bundledModulesPath: "../modules/",
bundledModulesPath: undefined,
editorServicesLogLevel: "Normal",
editorServicesWaitForDebugger: false,
powerShellExeIsWindowsDevBuild: false

0 comments on commit 5f9cfd6

Please sign in to comment.