Skip to content

Commit 610d50e

Browse files
Fix exit status 1 on analyze and extra directory
1 parent 7c03bd8 commit 610d50e

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ go.work
2222
go.work.sum
2323

2424
.idea/
25+
26+
cli-v2

cmd/analyze.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
package cmd
22

33
import (
4-
"codacy/cli-v2/tools"
54
"codacy/cli-v2/config"
5+
"codacy/cli-v2/tools"
66
"fmt"
7+
"github.com/spf13/cobra"
78
"log"
89
"os"
9-
"github.com/spf13/cobra"
10+
"path"
1011
)
1112

1213
var outputFolder string
1314

1415
func init() {
15-
analyzeCmd.Flags().StringVarP(&outputFolder, "output", "o", ".codacy/out/eslint.sarif", "where to output the results")
16+
analyzeCmd.Flags().StringVarP(&outputFolder, "output", "o", path.Join(".codacy", "out"), "where to output the results")
1617
rootCmd.AddCommand(analyzeCmd)
1718
}
1819

@@ -41,8 +42,7 @@ var analyzeCmd = &cobra.Command{
4142
log.Fatal("You need to specify the tool you want to run for now! ;D")
4243
}
4344

44-
msg := fmt.Sprintf("Running the tool %s. Output will be available at %s", args[0], outputFolder)
45-
fmt.Println(msg)
45+
fmt.Printf("Running the tool %s. Output will be available at %s\n", args[0], outputFolder)
4646
err = tools.RunEslintToFile(workDirectory, eslintInstallationDirectory, nodeBinary, outputFolder)
4747
if err != nil {
4848
log.Fatal(err)

tools/eslintRunner.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func RunEslintToString(repositoryToAnalyseDirectory string, eslintInstallationDi
2020
// * The local installed ESLint should have the @microsoft/eslint-formatter-sarif installed
2121
func runEslint(repositoryToAnalyseDirectory string, eslintInstallationDirectory string, nodeBinary string, outputFolder string) (string, error) {
2222
eslintInstallationNodeModules := filepath.Join(eslintInstallationDirectory, "node_modules")
23-
eslintJsPath := filepath.Join(eslintInstallationNodeModules, ".bin/eslint")
23+
eslintJsPath := filepath.Join(eslintInstallationNodeModules, ".bin", "eslint")
2424

2525
cmd := exec.Command(nodeBinary, eslintJsPath, "-f", "@microsoft/eslint-formatter-sarif")
2626

@@ -35,10 +35,8 @@ func runEslint(repositoryToAnalyseDirectory string, eslintInstallationDirectory
3535
nodePathEnv := "NODE_PATH=" + eslintInstallationNodeModules
3636
cmd.Env = append(cmd.Env, nodePathEnv)
3737

38-
out, err := cmd.Output()
39-
if err != nil {
40-
return "", err
41-
}
38+
// TODO eslint returns 1 when it finds errors, so we're not propagating it
39+
out, _ := cmd.Output()
4240

4341
return string(out), nil
4442
}

0 commit comments

Comments
 (0)