Skip to content

Commit

Permalink
Add ability to override aliases path and environment path in tasks in…
Browse files Browse the repository at this point in the history
… VSCode extension
  • Loading branch information
StevenLooman committed Nov 17, 2024
1 parent 9549096 commit 4e785fb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- Do not check abstract method parameters in UnusedVariableCheck if `check-parameters`.
- Fix sslr-magik-toolkit's "Evaluate XPath"-button.
- Add UndefinedVariable check to Sonar way profile.
- Add ability to override aliases path and environment path in tasks in VSCode extension.
- Several fixes.

### Breaking changes (reiterated from above)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export class MagikAliasTaskProvider implements vscode.TaskProvider, vscode.Dispo

public static readonly AliasType: string = 'run_alias';

private context: vscode.ExtensionContext;
private provider: vscode.Disposable;
private readonly context: vscode.ExtensionContext;
private readonly provider: vscode.Disposable;
private promise: Thenable<vscode.Task[]> | undefined = undefined;
private fileWatcher: vscode.FileSystemWatcher = undefined;

Expand Down Expand Up @@ -47,8 +47,8 @@ export class MagikAliasTaskProvider implements vscode.TaskProvider, vscode.Dispo
if (entry) {
const definition: AliasTaskDefinition = task.definition as AliasTaskDefinition;
const runAliasPath = getRunAliasPath();
const aliasesPath = getAliasesPath();
const environmentFile = getEnvironmentPath();
const aliasesPath = getAliasesPath(definition.aliasesPath);
const environmentFile = getEnvironmentPath(definition.environmentPath);
const commandLine = getStartAliasCommand(runAliasPath, aliasesPath, definition.entry, environmentFile, definition.args);
const shellExecutionOptions: vscode.ShellExecutionOptions = {
env: definition.env,
Expand Down Expand Up @@ -80,6 +80,16 @@ interface AliasTaskDefinition extends vscode.TaskDefinition {
* Environment variables.
*/
env?: Record<string, string>;

/**
* Override aliases path.
*/
aliasesPath?: fs.PathLike;

/**
* Override environment path.
*/
environmentPath?: fs.PathLike;
}

let _channel: vscode.OutputChannel;
Expand All @@ -100,11 +110,19 @@ function getRunAliasPath(): fs.PathLike {
return path.join(smallworldGisPath.toString(), 'bin', 'share', 'runalias');
}

function getEnvironmentPath(): fs.PathLike {
function getEnvironmentPath(environmentPath?: fs.PathLike): fs.PathLike {
if (environmentPath) {
return environmentPath;
}

return vscode.workspace.getConfiguration().get('magik.environment');
}

function getAliasesPath(): fs.PathLike {
function getAliasesPath(aliasesPath?: fs.PathLike): fs.PathLike {
if (aliasesPath) {
return aliasesPath;
}

return vscode.workspace.getConfiguration().get('magik.aliases');
}

Expand Down
8 changes: 8 additions & 0 deletions magik-language-server/client-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@
"env": {
"type": "object",
"description": "Environment variables"
},
"aliasesPath": {
"type": "path",
"description": "Override aliases path"
},
"environmentPath": {
"type": "path",
"description": "Override environment path"
}
}
}
Expand Down

0 comments on commit 4e785fb

Please sign in to comment.