-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use default nodejs path if not setted #17
- Loading branch information
1 parent
8170567
commit a43b4df
Showing
3 changed files
with
123 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
src/main/java/com/github/philippefichet/sonarlint4netbeans/NodeProcessWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* sonarlint4netbeans: SonarLint integration for Apache Netbeans | ||
* Copyright (C) 2020 Philippe FICHET. | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
* MA 02110-1301 USA | ||
*/ | ||
package com.github.philippefichet.sonarlint4netbeans; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.function.Consumer; | ||
import org.sonarsource.nodejs.ProcessWrapper; | ||
import org.sonarsource.nodejs.ProcessWrapperImpl; | ||
|
||
/** | ||
* Used to intercept nodejs path in NodeCommandBuilderImpl | ||
* @author FICHET Philippe <[email protected]> | ||
*/ | ||
public class NodeProcessWrapper implements ProcessWrapper { | ||
|
||
private final ProcessWrapperImpl processWrapper = new ProcessWrapperImpl(); | ||
private List<String> commandLineUsed = null; | ||
|
||
@Override | ||
public Process startProcess(List<String> commandLine, Map<String, String> env, Consumer<String> outputConsumer, Consumer<String> errorConsumer) throws IOException { | ||
commandLineUsed = new ArrayList<>(commandLine); | ||
return processWrapper.startProcess(commandLine, env, outputConsumer, errorConsumer); | ||
} | ||
|
||
@Override | ||
public boolean waitFor(Process process, long timeout, TimeUnit unit) throws InterruptedException { | ||
return processWrapper.waitFor(process, timeout, unit); | ||
} | ||
|
||
@Override | ||
public void interrupt() { | ||
processWrapper.interrupt(); | ||
} | ||
|
||
@Override | ||
public void destroyForcibly(Process process) { | ||
processWrapper.destroyForcibly(process); | ||
} | ||
|
||
@Override | ||
public boolean isMac() { | ||
return processWrapper.isMac(); | ||
} | ||
|
||
@Override | ||
public boolean isWindows() { | ||
return processWrapper.isWindows(); | ||
} | ||
|
||
@Override | ||
public String getenv(String name) { | ||
return processWrapper.getenv(name); | ||
} | ||
|
||
@Override | ||
public int exitValue(Process process) { | ||
return processWrapper.exitValue(process); | ||
} | ||
|
||
public Optional<List<String>> getCommandLineUsed() { | ||
return Optional.ofNullable(commandLineUsed); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters