Skip to content
This repository has been archived by the owner on Jul 8, 2019. It is now read-only.

#147 fix wrong working directory when linting with tslint > 5.2.0 #148

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions src/main/java/com/pablissimo/sonar/TsLintExecutorConfig.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.pablissimo.sonar;

import java.io.File;

import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.config.Settings;

Expand All @@ -15,10 +17,12 @@ public class TsLintExecutorConfig {
private String pathToTsLintOutput;

private Integer timeoutMs;
private File baseDir;

public static TsLintExecutorConfig fromSettings(Settings settings, SensorContext ctx, PathResolver resolver) {
TsLintExecutorConfig toReturn = new TsLintExecutorConfig();

toReturn.setBasedir(ctx.fileSystem().baseDir());
toReturn.setPathToTsLint(resolver.getPath(ctx, TypeScriptPlugin.SETTING_TS_LINT_PATH, TSLINT_FALLBACK_PATH));
toReturn.setConfigFile(resolver.getPath(ctx, TypeScriptPlugin.SETTING_TS_LINT_CONFIG_PATH, CONFIG_FILENAME));
toReturn.setRulesDir(resolver.getPath(ctx, TypeScriptPlugin.SETTING_TS_LINT_RULES_DIR, null));
Expand All @@ -31,6 +35,14 @@ public static TsLintExecutorConfig fromSettings(Settings settings, SensorContext
return toReturn;
}

public File getBasedir() {
return this.baseDir;
}

private void setBasedir(File baseDir) {
this.baseDir = baseDir;
}

public Boolean useExistingTsLintOutput() {
return this.pathToTsLintOutput != null && !this.pathToTsLintOutput.isEmpty();
}
Expand Down Expand Up @@ -95,4 +107,5 @@ public boolean shouldPerformTypeCheck() {
public void setShouldPerformTypeCheck(boolean performTypeCheck) {
this.shouldPerformTypeCheck = performTypeCheck;
}

}
3 changes: 2 additions & 1 deletion src/main/java/com/pablissimo/sonar/TsLintExecutorImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ private Command getBaseCommand(TsLintExecutorConfig config, String tempPath) {
.create("node")
.addArgument(this.preparePath(config.getPathToTsLint()))
.addArgument("--format")
.addArgument("json");
.addArgument("json")
.setDirectory(config.getBasedir());

String rulesDir = config.getRulesDir();
if (rulesDir != null && rulesDir.length() > 0) {
Expand Down