cmd/cue/cmd: fix stdin usage for import

Closes #116

Change-Id: I23b51fb9580002bf8de426d573a402fd8589503f
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/5242
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cmd/cue/cmd/orphans.go b/cmd/cue/cmd/orphans.go
index f7b764d..02b35d3 100644
--- a/cmd/cue/cmd/orphans.go
+++ b/cmd/cue/cmd/orphans.go
@@ -311,6 +311,9 @@
 }
 
 func newName(filename string, i int) string {
+	if filename == "-" {
+		return filename
+	}
 	ext := filepath.Ext(filename)
 	filename = filename[:len(filename)-len(ext)]
 	if i > 0 {
diff --git a/cmd/cue/cmd/testdata/script/issue116.txt b/cmd/cue/cmd/testdata/script/issue116.txt
new file mode 100644
index 0000000..c52abbd
--- /dev/null
+++ b/cmd/cue/cmd/testdata/script/issue116.txt
@@ -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"
+}
\ No newline at end of file