If my vault is located in say C:\Users\Jare\Desktop\Jare's vault\, I’d like to get this path somehow in my plugin’s TypeScript code.
I’m very new to developing plugins for Obsidian and to NodeJS and Electron apps too, but I have managed to learn quite well how the sample plugin works.
I just accidentally found an answer to this, when I was just interested in another plugin and read its source code.
(Edit: While the following code may work, please find a better solution from my newer post further down this thread.)
//@ts-ignore
this.app.vault.adapter.basePath
In order to use basePath, you need to instruct typescript not to yell about basePath not being defined during compiling. Hence this has the line //@ts-ignore. I don’t know why this supression is needed - I mean: why the property is not defined in the first place? If anyone else knows a better way to get the path, please let me know.
The plugin-dev channel in discord is really helpful when it comes to API questions, there’s a lot more activity than in this forum section. So I can only recommend it.
You are welcome! But I’m not sure if you should skip checking the adapter’s class. Maybe there can be cases where it’s something different than FileSystemAdapter?