Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
cmd/cue/cmd: fix stdin usage for import
Browse files Browse the repository at this point in the history
Closes #116

Change-Id: I23b51fb9580002bf8de426d573a402fd8589503f
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/5242
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
  • Loading branch information
mpvl committed Mar 7, 2020
1 parent d56457f commit 485f389
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/cue/cmd/orphans.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ func (x *listIndex) label(label ast.Label) *listIndex {
}

func newName(filename string, i int) string {
if filename == "-" {
return filename
}
ext := filepath.Ext(filename)
filename = filename[:len(filename)-len(ext)]
if i > 0 {
Expand Down
24 changes: 24 additions & 0 deletions cmd/cue/cmd/testdata/script/issue116.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
stdin in
cue import yaml: -
cmp stdout stdout-cue

stdin in
cue export yaml: -
cmp stdout stdout-json

stdin in
cue eval yaml: -
cmp stdout stdout-cue

stdin in
cue def yaml: -
cmp stdout stdout-cue

-- in --
foo: bar
-- stdout-cue --
foo: "bar"
-- stdout-json --
{
"foo": "bar"
}

0 comments on commit 485f389

Please sign in to comment.