|
Name | Description |
---|---|
runOnSave.statusMessageTimeout |
Specify the timeout millisecond after which the status bar message will hide, default value is 3000 , means 3 seconds. |
runOnSave.commands |
Specify the array of shell commands to execute and related info, its child options as below. |
runOnSave.shell |
Specify in which shell the commands are executed, defaults to the default vscode shell. |
Command Options
Name | Description |
---|---|
commands[].match |
Specify a RegExp source to match file path. E.g.: \\.scss$ can used to match scss files. |
commands[].notMatch |
Specify a RegExp source, the file that whole path match it will be excluded. E.g.: [\\\\\\/]_[\\w-]+\\.scss$ can be used to exclude scss library files. |
commands[].globMatch |
Specify a glob expression, the file that whole path match it will be included. E.g.: **/*.scss will match all scss files. Here it didn't provide a globNotMatch pattern because glob expression can do so, please reference to https://github.com/isaacs/node-glob#glob-primer. |
commands[].command |
Specify the shell command to execute. You may include variable substitution like what to do in VSCode Tasks. |
commands[].forcePathSeparator |
Force path separator in variable substitution to be / , \\ , default is not specified. |
commands[].async |
All the commands with async: false will run in a sequence, means run next after previous completed. Default value is true . |
commands[].runningStatusMessage |
Specify the status bar message when the shell command begin to run, supports variable substitution too. Only works when runIn=backend . |
commands[].finishStatusMessage |
Specify the status bar message after the shell command finished executing, also supports variable substitution. Only works when runIn=backend . |
commands[].workingDirectoryAsCWD |
Specify the vscode working directory as shell CWD (Current Working Directory). Only works when runIn=backend . |
commands[].runIn |
See list below. |
backend
: Run command silently and show messages in output channel, you can specify runningStatusMessage and finishStatusMessage to give you a little feekback. Choose this when you don't want to be disturbed.terminal
: Run command in vscode terminal, which keeps message colors. Choose this when you want to get feedback details.vscode
: Run vscode's command. Choose this if you want to execute vscode's own command or a command of a particular extension.
Sample Configuration
{
"runOnSave.statusMessageTimeout": 3000,
"runOnSave.commands": [
{
// Match scss files except names start with `_`.
"match": ".*\\.scss$",
"notMatch": "[\\\\\\/]_[^\\\\\\/]*\\.scss$",
"command": "node-sass ${file} ${fileDirname}/${fileBasenameNoExtension}.css",
"runIn": "backend",
"runningStatusMessage": "Compiling ${fileBasename}",
"finishStatusMessage": "${fileBasename} compiled"
},
{
// Match less files except names start with `_`.
"globMatch": "**/[^_]*.less",
"command": "node-sass ${file} ${fileDirname}/${fileBasenameNoExtension}.css",
"runIn": "terminal"
},
{
"match": ".*\\.py$",
"command": "python.runLinting",
"runIn": "vscode"
}
]
}
Variable Substitution
Can be used in command
, runningStatusMessage
, finishStatusMessage
, globMatch
.
Note that if forcePathSeparator
specified, separators in these variables will be replaced.
For more details please refer to VSCode Tasks.
Name | Description |
---|---|
${workspaceFolder} |
the path of the folder opened in VS Code. |
${workspaceFolderBasename} |
the name of the folder opened in VS Code without any slashes (/). |
${file} |
the path of current opened file. |
${fileBasename} |
the basename part of current opened file. |
${fileBasenameNoExtension} |
the basename part without extension of current opened file. |
${fileDirname} |
the dirname path part of current opened file. |
${fileDirnameRelative} |
the relative dirname path part of current opened file. |
${fileExtname} |
the extension part of current opened file. |
${fileRelative} |
the shorter relative path from current vscode working directory. |
${cwd} |
the task runner's current working directory on startup. |
${env.Name} |
reference environment variables. |
Commands
The following commands are exposed in the command palette
Run On Save: Enable
- to enable the extensionRun On Save: Disable
- to disable the extension
References
This plugin inspired from these plugins:
vscode-runonsave and vscode-save-and-run.
License
MIT