emeraldwalk / vscode-runonsave

Visual Studio Code extension to run commands whenever a file is saved.
Apache License 2.0
182 stars 57 forks source link

how to match exclude .vscode folder #80

Closed ruanimal closed 1 month ago

ruanimal commented 1 year ago

I wan't to exclude vscode config folder from regex match, but not work.

I have try these

config

{
    "emeraldwalk.runonsave": {
        "autoClearConsole": true,
        "commands": [
            {
                "match": ".*",
                "isAsync": true,
                "cmd": "rsync -av --exclude=target/ \"${workspaceFolder}/\"  /somewhere"
            },
        ]
    }
}
iwconfig commented 8 months ago

"notMatch": ".vscode/*"

bmingles commented 1 month ago

@ruanimal I think you were close but starting the regex with ^ is usually not going to be what you want since the match is against the full path.

I think this should do what you want:

{
    "emeraldwalk.runonsave": {
        "autoClearConsole": true,
        "commands": [
            {
                "match": ".*",
                "notMatch": "\\.vscode/.*$",
                "isAsync": true,
                "cmd": "rsync -av --exclude=target/ \"${workspaceFolder}/\"  /somewhere"
            },
        ]
    }
}

The notMatch option was not previously documented (sorry about that). It has been added to documentation in https://github.com/emeraldwalk/vscode-runonsave/pull/100