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

Commit

Permalink
#147 fix wrong working directory when linting with tslint > 5.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Gebauer committed Jun 8, 2017
1 parent 55d5a6c commit a04ca27
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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

0 comments on commit a04ca27

Please sign in to comment.