Is it possible to create a VS Code extension that runs a specific gulp task?
Asked Answered
M

2

0

Since I'm a lazy programmer, I've built a gulp task that does some minor tasks for me but I'd like to turn this into an extension so I can install it on my computer and it just "works". Like I install it, boot up VS code and the tasks execute and start watching my code automatically.

I haven't found much things online but then again I could be googling the wrong things. Anything helps - thanks!

Muskogee answered 24/6, 2019 at 14:33 Comment(0)
P
0

Have a look at run task on folderOpen option: vscode docs.

This works for me:

// in tasks.json

{
  "label": "Tasks: copy3",
  "type": "shell",
  "command": "gulp",
  "args": [
    "copy3",
    "--file",
    "${fileBasename}"
  ],
  "problemMatcher": [],
  "runOptions": {
    "runOn": "folderOpen"
  }
},

Now the copy3 task in gulpfile.js will automatically be run when that folder (or workspace) is opened. You may have to select Tasks: Allow Automatic Tasks in Folder first in the command palette. And definitely reload.

No extension - it is built-in behaviour more recently. See run task on folder open.

Ponce answered 25/6, 2019 at 2:3 Comment(0)
T
0

Looks like Yuki Doi had you to it with "Blade Runner". This extension does exactly what you're looking for, it automatically runs build task when a folder is opened.

Related question

Tafilelt answered 24/6, 2019 at 18:57 Comment(0)
P
0

Have a look at run task on folderOpen option: vscode docs.

This works for me:

// in tasks.json

{
  "label": "Tasks: copy3",
  "type": "shell",
  "command": "gulp",
  "args": [
    "copy3",
    "--file",
    "${fileBasename}"
  ],
  "problemMatcher": [],
  "runOptions": {
    "runOn": "folderOpen"
  }
},

Now the copy3 task in gulpfile.js will automatically be run when that folder (or workspace) is opened. You may have to select Tasks: Allow Automatic Tasks in Folder first in the command palette. And definitely reload.

No extension - it is built-in behaviour more recently. See run task on folder open.

Ponce answered 25/6, 2019 at 2:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.