Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename lime.command to lime.executable #37

Merged
merged 3 commits into from
Apr 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

* Added support for the `haxe.taskPresentation` setting in vshaxe 1.11.0 ([#31](https://github.com/openfl/lime-vscode-extension/issues/31))
* Added support for the new problem matchers in vshaxe 1.11.0 ([#31](https://github.com/openfl/lime-vscode-extension/issues/31))
* Added `lime.command` for using a custom Lime command ([#36](https://github.com/openfl/lime-vscode-extension/issues/36))
* Added `lime.executable` for using a custom Lime command ([#36](https://github.com/openfl/lime-vscode-extension/issues/36))
* Added an error message in case the `lime display` command fails ([#36](https://github.com/openfl/lime-vscode-extension/issues/36))

1.1.0 (04/04/2018)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
"Final"
]
},
"lime.command": {
"description": "The Lime command to call in tasks and for `lime display`",
"lime.executable": {
"description": "The Lime executable to call in tasks and for `lime display`. Can be multiple arguments separated by spaces or a path to an executable.",
"type": "string",
"default": "lime"
}
Expand Down
37 changes: 22 additions & 15 deletions src/lime/extension/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Main {
private var selectTargetItem:StatusBarItem;
private var targetItems:Array<TargetItem>;
private var haxeEnvironment:DynamicAccess<String>;
private var limeCommand:String;
private var limeExecutable:String;


public function new (context:ExtensionContext) {
Expand All @@ -47,8 +47,6 @@ class Main {

hasProjectFile = false;

try {

if (getProjectFile () != "") {

hasProjectFile = true;
Expand Down Expand Up @@ -85,8 +83,6 @@ class Main {

}

}


private function construct ():Void {

Expand Down Expand Up @@ -195,7 +191,7 @@ class Main {

var task = new Task (definition, name, "lime");

task.execution = new ShellExecution (limeCommand + " " + args.join (" "), { cwd: workspace.workspaceFolders[0].uri.fsPath, env: haxeEnvironment });
task.execution = new ShellExecution (limeExecutable + " " + args.join (" "), { cwd: workspace.workspaceFolders[0].uri.fsPath, env: haxeEnvironment });

if (group != null) {

Expand Down Expand Up @@ -233,10 +229,21 @@ class Main {
}


private function getCommand ():String {
private function getExecutable ():String {

var executable = workspace.getConfiguration ("lime").get ("executable");
if (executable == null) {

executable = "lime";

var command = workspace.getConfiguration ("lime").get ("command");
return if (command == null) "lime" else command;
}
// naive check to see if it's a path, or multiple arguments such as "haxelib run lime"
if (FileSystem.exists(executable)) {

executable = '"' + executable + '"';

}
return executable;

}

Expand Down Expand Up @@ -496,11 +503,11 @@ class Main {

}

var oldLimeCommand = limeCommand;
limeCommand = getCommand ();
var limeCommandChanged = oldLimeCommand != limeCommand;
var oldLimeExecutable = limeExecutable;
limeExecutable = getExecutable ();
var limeExecutableChanged = oldLimeExecutable != limeExecutable;

if (isProviderActive && (!initialized || limeCommandChanged)) {
if (isProviderActive && (!initialized || limeExecutableChanged)) {

if (!initialized) {

Expand Down Expand Up @@ -567,14 +574,14 @@ class Main {

if (!hasProjectFile || !isProviderActive) return;

var commandLine = limeCommand + " " + getCommandArguments ("display").join (" ");
var commandLine = limeExecutable + " " + getCommandArguments ("display").join (" ");
commandLine = StringTools.replace (commandLine, "-verbose", "");

ChildProcess.exec (commandLine, { cwd: workspace.workspaceFolders[0].uri.fsPath }, function (err, stdout:Buffer, stderror) {

if (err != null && err.code != 0) {

var message = 'Lime completion setup failed. Is the lime command available? Try running "lime setup" or changing the "lime.command" setting.';
var message = 'Lime completion setup failed. Is the lime command available? Try running "lime setup" or changing the "lime.executable" setting.';
var showFullErrorLabel = "Show Full Error";
window.showErrorMessage (message, showFullErrorLabel).then (function (selection) {

Expand Down