Use Visual Studio Code Tasks with Gulp 4.0 - visual-studio-code

I am in the process of switching a project from Gulp 3.9.1 (npm install gulp) to Gulp 4.0 (npm install gulp-4.0.build), but when I do this, Visual Studio Code is no longer able to auto-detect the tasks in my gulpfile.js. In both cases, gulp is installed locally.
My .vscode/tasks.json looks like:
{
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"showOutput": "always"
}
Looking at the Tasks output, I see the following message:
Running gulp --tasks-simple didn't list any tasks. Did you run npm install?
Can you use Gulp 4.0 with VS Code and have it autodetect the tasks? If so, what steps do I need to follow to get it setup?

Yes, you can use vscode and gulp4.0. I would look at how to upgrade to gulp4.0.
Did you uninstall gulp3.9.1 first?
You should also install gulp4.0 both locally and globally!
Then run
gulp -v
to make sure it worked. vsCode should detect both tasks in your tasks.json file and from your gulpfile.js. You are using the older tasks.json version 0.1.0. Here is an example of a tasks.json file which allows me to type "gulp sync" in the command line from anywhere in the workspaceRoot and run that task:
{
"version": "2.0.0",
"tasks": [
{
"label": "Start server and process files",
"command": "gulp",
"args": [
"sync"
],
"type": "shell",
"options": {
"cwd": "${workspaceRoot}"
}
}
]
}
It runs the "sync" task I defined in my gulpfile.js. In fact you can assign a hotkey combo to that such as:
{ "key": "shift+escape",
"command": "workbench.action.tasks.runTask",
"args": "Start server and process files"
},
in your keybindings.json.

Related

Can't debug Rust code inside vscode with WSL setup

I can't debug my rust code which is in WSL with VScode which is installed on my windows. I get these errors during debug.
Error: there is no registered task type 'codelldb.cargo'. Did you miss installing an extension that provides a corresponding task provider?
Error: there is no registered task type 'codelldb.cargo'. Did you miss installing an extension that provides a corresponding task provider?
Here is my launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'foo'",
"cargo": {
"args": [
"build",
"--bin=foo",
"--package=foo"
],
"filter": {
"name": "foo",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
]
}
Strangely I can run my code using vscode & getting expected output.
I have installed below extension for WSL in vscode
codeLLDB
rust-analyzer
these are the versions of software
WSL: version 1
vscode: 1.72.2
windows : Windows 10
What I'm missing here
This issue is due to WSL version. Issue got fixed after upgrading WSL from v1 to v2

VSCode - how to keybind an external command

Im trying to run "puppet-lint -f (currently open file)
The Puppet extenstion provides puppet-lint check, but doesnt auto fix any issues, it just gives warnings. How can I add a keyboard shortcut to run "puppet-lint -f" on a file Im currently editing?
Thanks
I don't know anything about the Puppet extension but in general here is how you can bind a shell command to a keychord:
Make a task for it (.vscode/tasks.json):
{
"version": "2.0.0",
"tasks": [{
"label": "node version",
"command": "node",
"args": [
"-v"
],
"type": "shell"
}]
}
In the args you may use ${file} for the current file.
Then add this option to your keybindings.json (you can find them in Command Palette under “Preferences: Open keyboard shortcuts (JSON)”):
{
"key": "shift+escape",
"command": "workbench.action.tasks.runTask",
"args": "node version"
},
co-author of the extension here. You can have the Puppet VSCode Extension run puppet-lint fix on the current file by using the Format Document command. You can then configure VSCode to run format on save.

Testing VS Code extension with npm

For testing my visual studio code extension I need to open a specific folder.
I've inserted the folder path into the args property of Launch Test Configuration as explained here:
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["${workspaceRoot}/../../RIOT", "--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [ "${workspaceRoot}/out/test/**/*.js" ],
"preLaunchTask": "npm: watch"
}
This works fine if I manually open VS Code and start the test with Debug: Start (F5).
But I want to run tests in batch mode with npm test and this does not work.
How to configure the folder under test when using npm test?
Set the folder under test with CODE_TESTS_WORKSPACE environment variable:
> export CODE_TESTS_WORKSPACE=whatever_folder
> npm test

Task with 'runner' not working as expected in VS Code

In VS Code 1.13.1, running in Windows Creator Update, I have defined this task in tasks.json:
{
"version": "0.1.0",
"runner": "terminal",
"command": "echo",
"isShellCommand": true,
"args": ["Hello world"],
"showOutput": "always"
}
When I run the task I see this message in the integrated terminal:
Terminal will be reused by tasks, press any key to close it.
But I don't see "Hello world". Why?
I don't know if you solved it yet, but I was having the same problem until I changed the terminal on settings.json from
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
to
"terminal.integrated.shell.windows": "C:\\WINDOWS\\Sysnative\\cmd.exe"
If your settings.json file does not have this line you can add and see if the problem goes away.

How to configure VS Code on Windows to run a task in WSL?

I am running VS Code 1.6 on Windows and have configured the integrated terminal to be bash:
"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe",
I want to build my C++ project using make running in WSL. So I defined a task:
{
"version": "0.1.0",
"command": "make",
"isShellCommand": true,
"args": [""],
"showOutput": "always"
}
How can I configure that task to run in WSL?
How can I set the directory in which make should run? (not the root directory of the folder opened in Code, but a subfolder of it).
Try this (replacing as appropriate:
{
"version": "0.1.0",
"command": "c:\\Windows\\sysnative\\bash.exe",
"isShellCommand": true,
"args": ["-c 'cd /mnt/c/<path>; make'"],
"showOutput": "always"
}