Skip to content

Provide current workspace path in $psEditor.Workspace #236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gerane opened this issue May 18, 2016 · 1 comment
Closed

Provide current workspace path in $psEditor.Workspace #236

gerane opened this issue May 18, 2016 · 1 comment
Labels
Issue-Enhancement A feature request (enhancement).
Milestone

Comments

@gerane
Copy link
Contributor

gerane commented May 18, 2016

It would be nice to be able to get access to things like the currently opened file's path, file's root directory, project's root directory and things like that.

An example usage might be to create an Editor Command that creates a Pester Test for the currently opened file and places it in the appropriate Tests directory for that Project.

A user might have projects with different locations of their Tests. It would be beneficial to have a config file. One could eventually be provided by Editor services, but if you have access to the Project root, you could have your own config file where you gather settings such as Pester Test directory, psake script, psdeploy script, or anything like that.

So your scripts could just get the ProjectRoot and then access their own config file for Settings. So two different projects could have different structure or layouts, but you could still create editor commands that is aware of their project differences.

An Example:

Project: A
Returns 'ProjectRoot\Tests' for Tests Directory

Project: B
Returns 'ProjectRoot' for Tests Directory

@daviwil daviwil changed the title Extend $PSEditor to give access to additional environment information and a way to store configurations. Provide current workspace path in $psEditor.Workspace May 18, 2016
@daviwil
Copy link
Contributor

daviwil commented May 18, 2016

You can get the path of the currently opened file from $psEditor.CurrentFile.Path. We should definitely add something to get the workspace path from the $psEditor.Workspace object though. I could also provide a WorkspacePath property on FileContext which would give you the file's path relative to the workspace path. Anything else you could probably get using System.IO.Path's methods.

@daviwil daviwil added the Issue-Enhancement A feature request (enhancement). label May 18, 2016
@daviwil daviwil added this to the 0.7.0 milestone May 18, 2016
@daviwil daviwil modified the milestones: 0.7.0, 0.8.0 Sep 2, 2016
daviwil added a commit that referenced this issue Dec 9, 2016
This change adds a new Path property to the EditorWorkspace class which
gets exposed through to the psEditor API.  This is useful for extension
authors who want to perform operations based on the workspace path.

Resolves #236.
@daviwil daviwil closed this as completed in 29617f8 Dec 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement A feature request (enhancement).
Projects
None yet
Development

No branches or pull requests

2 participants