#Getting directory.Name() doesn't return expected value
1 messages · Page 1 of 1 (latest)
if i use the same logic but for file.Name() it returns the correct value. I was expecting directory to work the same way
Hey Julien!
This behavior is actually expected (IMO 😇)
What’s happening is:
- When you run
host directory --path ./functions, you’re making./functionsthe root of the snapshot. The "root" directory’s canonical name is/, so that’s whydirectory.Name()gives you/. file.Name()behaves differently because files are always leaves in the snapshot graph, so they always have a basename.
In order to get the expected name, you could give it a parent context:
$ ls
functions
$ dagger core host directory --path . directory --path functions name
▶ connect 0.5s
✔ loading type definitions 0.4s
✔ parsing command line arguments 0.0s
✔ host: Host! 0.0s
▶ .directory(path: "."): Directory! 0.1s ✔ 1
✔ .directory(path: "functions"): Directory! 0.0s
▶ .name: String! 0.0s
functions/ # <--- expected name