Skip to content

Commit

Permalink
feat: output dir to dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Sep 16, 2020
1 parent b0ef944 commit 3acfea3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/cloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package cmd
import (
"fmt"
"github.com/boyter/scc/processor"
"github.com/phodal/coca/cmd/config"
"github.com/spf13/cobra"
"io/ioutil"
"log"
"os"
"path/filepath"
)

Expand All @@ -25,21 +27,25 @@ var clocCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
if clocConfig.ByDirectory {
var dirs []string
first_file, err := ioutil.ReadDir(args[0])
firstFile, err := ioutil.ReadDir(args[0])
if err != nil {
log.Fatal(err)
}

for _, f := range first_file {
for _, f := range firstFile {
if f.IsDir() {
dirs = append(dirs, filepath.FromSlash(args[0] + "/" + f.Name()))
}
}

os.Mkdir(config.CocaConfig.ReporterPath + "/cloc/", os.ModePerm)

processor.Format = "cloc-yaml"

for _, dir := range dirs {
baseName := filepath.Base(dir)
processor.DirFilePaths = []string{dir}
processor.FileOutput = filepath.FromSlash(config.CocaConfig.ReporterPath + "/cloc/" + baseName + ".yaml")
processor.ConfigureGc()
processor.ConfigureLazy(true)
processor.Process()
Expand Down

0 comments on commit 3acfea3

Please sign in to comment.