Skip to content

Commit

Permalink
use unix style for proto imports
Browse files Browse the repository at this point in the history
  • Loading branch information
AriehSchneier committed Nov 19, 2024
1 parent 9e36936 commit 655f512
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Binary file modified internal/bundles/assets/import_proto_cli.arraiz
Binary file not shown.
11 changes: 10 additions & 1 deletion pkg/importer/proto/proto_parser.arrai
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,22 @@ let parseFile =
# syntax: 'proto3'
# )
# }

# imports will use / so replace \ with / if on windows
let toUnixPath =
let func = cond //os.path_separator {
"\\": \in //seq.sub("\\", "/", in),
_: \in in,
};
\path func(path);

let import = \(importPaths?:paths:[], ...) \files
let localImports = //{/pkg/importer/proto/bundled_files/local_imports};
let isLocal = \path localImports(path)?:false && true;
let fileMaps = paths >> \path
# //os.tree() trims './' so remove it
let pathTrimmed = cond {path='.':'', _://seq.trim_prefix('./',path)};
{pathTrimmed: //os.tree(path) => .path where //seq.has_suffix(".proto", .)};
{pathTrimmed: //os.tree(path) => toUnixPath(.path) where //seq.has_suffix(".proto", .)};
let _ = //log.print((:fileMaps));
# `path` returns the full filepath for the file being processed
# `file` the file being processed
Expand Down
13 changes: 2 additions & 11 deletions pkg/importer/protobuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package importer

import (
"fmt"
"path"
"strings"

"github.com/pkg/errors"
Expand Down Expand Up @@ -101,11 +100,11 @@ func buildImporterArgs(a *protobufImporterArgs) ([]string, error) {
args = append(args, "--spec", a.specContent)
}
if a.specPath != "" {
args = append(args, "--input", path.Clean(a.specPath))
args = append(args, "--input", a.specPath)
}

if a.importPaths != "" {
args = append(args, "--import-paths", cleanImportPaths(a.importPaths))
args = append(args, "--import-paths", a.importPaths)
}

if a.shallow {
Expand All @@ -114,11 +113,3 @@ func buildImporterArgs(a *protobufImporterArgs) ([]string, error) {

return args, nil
}

func cleanImportPaths(importPaths string) string {
split := strings.Split(importPaths, ",")
for i, p := range split {
split[i] = path.Clean(p)
}
return strings.Join(split, ",")
}

0 comments on commit 655f512

Please sign in to comment.