Git Product home page Git Product logo

vscode-watch-run's Introduction

watch-run README

Features

This extension will watch specified file and run the task when that is changed.

save and run

Extension Settings Example

Note: If you change settings.json, call "Apply settings" from the menu.

  • (project root)/.vscode/settings.json : list of target items.
{
    // If you change settings.json, call "Apply settings" from the menu.
    "watch-run.targetList": [
        {
            "target": "**/*.txt",
            "task": "show_filename"
        },
        {
            "target": "/index.html",
            "task": "show_html"
        },
        {
            "target": "/js/*.js",
            "task": "run_js"
        },
        {
            "regexp": "index-\\d+.html",
            "task": "show_index_number_html"
        }
    ]
}

tasks.json settings example

  • (project root)/.vscode/tasks.json : Write tasks here. usually generated from Configure Tasks menu.
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "show_html",
            "type": "shell",
            "command": "start ${file}"
        },
        {
            "label": "show_filename",
            "type": "shell",
            "command": "echo \"File:${file}\""
        },
        {
            "label": "run_js",
            "type": "shell",
            "command": "node ${input:run_js_file}"
        },
        {
            "label": "show_index_number_html",
            "type": "shell",
            "command": "start ${file}"
        }
    ],
    "inputs": [
        {
            "id": "run_js_file",
            "type": "command",
            "command": "watch-run.getFilename",
            "args" : "run_js"
        }
    ]
}

How work this example?

  • edit somewhere_dir/something.txt show filename in console from the task labeled "show_filename".

  • edit (workspace_root)/js/something.js run JavaScript on node command in the task labeled "run_js".

  • edit (workspace_root)/index.html run the task labeled "show_filename" to open index.html in browser.(in Windows)

  • edit somewhere_dir/index-1234.html

  • edit somewhere_dir/index-256.html open index-{number}.html in browser (in Windows)

How to get part of changed file

  1. define in "inputs" section like the following.
    "inputs": [
        {
            "id": "inputId",
            "type": "command",
            "command": "watch-run.getFilename",
            "args" : "run_js"
        }
    ]
  • the "args" is the same as the label of task.
  1. use ${input:inputId} in command of task to get the path.

Command example

path : c:\work\temp\file.ext

Command Value
getFilename c:\work\temp\file.ext
getDirname c:\work\temp
getBasename file.ext
getExtname .ext
getFilenameWithoutExtension file

Releases

CHANGELOG.md

vscode-watch-run's People

Contributors

boukichi avatar dependabot[bot] avatar

Stargazers

toni dy avatar  avatar  avatar Agustin Ottobre avatar Luiz avatar sdhizumi avatar  avatar 0xcb avatar

Watchers

 avatar James Cloos avatar Simon avatar

vscode-watch-run's Issues

not working

does this extension auto activated when vscode is starting? I think it's not woking

Does not support multiple folders paths from workspace

Hello,
Using version : 1.28.1
Platform: WIndows 10

I have a workspace looking at two folders and all the task and changes from only one is being applied. Can this be made to be workspace friendly? Thank you. Good day.

".vscode/finished-tasks" as `target` doesn't work

Hi.
I tried setting ".vscode/finished-tasks", "./.vscode/finished-tasks" and, I believe, even "**/finished-tasks" as target and changing that file didn't tigger any action. Is it intentional?

('finished-tasks' is just a regular text file.)

Changed file variable

Thank you for this extension!
Is there a variable that I can use in tasks configuration to catch what's file have been changed?

regex

Allow regex and glob

No support for VSCode actions

Hi.
Firstly, I thought this extension is all about execution VSCode actions. Now I know it's not, but I believe it could be quite useful feature. I personally wanted to use it to restart debugging session when specific file changed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.