Skip to content
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

Run tasks in Integrated Terminal on workspace startup #2383

Open
gaelcolas opened this issue Dec 20, 2019 · 3 comments
Open

Run tasks in Integrated Terminal on workspace startup #2383

gaelcolas opened this issue Dec 20, 2019 · 3 comments
Labels
Area-Tasks Issue-Enhancement A feature request (enhancement).

Comments

@gaelcolas
Copy link

Summary of the new feature

As a user of standardized pipeline automation (same build on over 50 DSC repos), I want to be able to set my Integrated Terminal session when I open the repository (set the $Env:PSModulePath for that session to path within the workspace, and alert of missing required modules defined in a RequiredModules.psd1 file).

Proposed technical implementation details (optional)

This could be handled by a task, currently we're running ./build.ps1 -tasks noop, but it should runOn when the folderOpen, IN the integrated terminal.

The task looks like this:

{
    "version": "2.0.0",
    "_runner": "terminal",
    "tasks": [
        {
            "label": "bootstrap_environment",
            "type": "shell",
            "command": "& ${cwd}/build.ps1",
            "args": ["-Tasks","noop"],
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": false,
                "panel": "shared",
                "showReuseMessage": true,
                "clear": false
            },
            "runOptions": {
                "runOn": "folderOpen"
            },
            "problemMatcher": [
			    //...
			]
		}
	]
}

The only "missing" part here is that it's not running in the integrated terminal.

Even better would be to enable those tasks to be "Optionally Integrated within the VSCode PowerShell extension", so that we could run the same tasks either inside or outside the integrated terminal (useful to do validate a build/test run on a clean session).

We could imagine having powershell extension configurations in settings.json like so:

"powershell.integratedConsole.startupTask": "bootstrap_environment",
"powershell.tasks": [
	"${bootstrap_environment}"
]
@ghost ghost added the Needs: Triage Maintainer attention needed! label Dec 20, 2019
@JustinGrote
Copy link
Collaborator

JustinGrote commented Dec 27, 2019

As a workaround, you could add code to your VSCode specific profile prompt {} function that, if you are in a directory that matches a particular pattern, to run that check and display the error at the console. You could then set a global variable so that it doesn't run it every time the prompt comes up, just upon first access.

Example (pseudocode, I didn't actually test this)

function prompt {
if ($PWD -match '/my/projects/folder/.*' -and $PWD -notin $GLOBAL:MyAlreadyTestedFolders) {
   build.ps1 -tasks noop $pwd
   #Your script at this point would issue write-warning for any issues
   $GLOBAL:MyAlreadyTestedFolders += $PWD
}

#Prompt code goes here
}

@gaelcolas
Copy link
Author

The main goal is to share that task to setup contributors' session. We can't share a prompt automatically afaik.

@JustinGrote
Copy link
Collaborator

@gaelcolas With the runup to PS7 it'd probably be a while before this got implemented especially because it may not be something the extension can do directly but requires some vscode-level changes (since the task json definition is defined there), so this would be a workaround in the meantime.

You can set a prompt from a script you could instruct your users to use, but that doesn't do you much better than just having them run your build script. I personally would not want a project executing arbitrary code on startup without my confirmation so there's a security aspect here that has to be carefully considered as well.

@SydneyhSmith SydneyhSmith added Area-Startup Area-Tasks Issue-Enhancement A feature request (enhancement). and removed Needs: Triage Maintainer attention needed! Area-Startup labels Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Tasks Issue-Enhancement A feature request (enhancement).
Projects
None yet
Development

No branches or pull requests

3 participants