Skip to content

Commit

Permalink
Fix gem build and simplify bundle install by running them from directory
Browse files Browse the repository at this point in the history
  • Loading branch information
PyvesB committed Feb 20, 2022
1 parent ae33670 commit ecb6e16
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Pierre-Yves B. and others.
* Copyright (c) 2019-2022 Pierre-Yves B. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -12,6 +12,8 @@
*******************************************************************************/
package io.github.pyvesb.eclipse_solargraph.launch.run;

import java.io.File;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugPlugin;
Expand All @@ -27,16 +29,17 @@ public class BundleGemRunShortcut implements IResourceLaunchShortcut {
public void launchResource(IResource resource, String mode) {
Launch launch = new Launch(null, ILaunchManager.RUN_MODE, null);
DebugPlugin.getDefault().getLaunchManager().addLaunch(launch);
String command = getBaseCommand(resource) + resource.getLocation().toOSString();
String command = getBaseCommand(resource);
String[] absolutePlatformCommand = CommandHelper.getAbsolutePlatformCommand(command);
File workingDirectory = resource.getLocation().removeLastSegments(1).toFile();
Job.create("Running " + command, r -> {
Process process = DebugPlugin.exec(absolutePlatformCommand, null);
Process process = DebugPlugin.exec(absolutePlatformCommand, workingDirectory);
DebugPlugin.newProcess(launch, process, command);
}).schedule();
}

private String getBaseCommand(IResource resource) {
return "Gemfile".equals(resource.getName()) ? "bundle install --gemfile=" : "gem build ";
return "Gemfile".equals(resource.getName()) ? "bundle install" : "gem build";
}

}

0 comments on commit ecb6e16

Please sign in to comment.