This repository has been archived by the owner on May 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Jobs
Marcel Kloubert edited this page Jun 13, 2021
·
2 revisions
Jobs can be used to run tasks, like scripts or shell commands, periodically.
Create a jobs
section to the settings.json
file in the .vscode
sub folder of your workspace and add one or more entry:
{
"ego.power-tools": {
"jobs": [
{
"name": "My job",
"description": "A job that runs all 30 seconds.",
"time": "*/30 * * * * *",
"action": {
"type": "script",
"script": "my_job.js"
}
}
]
}
}
For that example, create a my_job.js
file in your .vscode
folder and use the following skeleton:
exports.execute = async (args) => {
// args => https://egomobile.github.io/vscode-powertools/api/interfaces/_contracts_.jobitemscriptactionarguments.html
// s. https://code.visualstudio.com/api/references/vscode-api
const vscode = args.require('vscode');
vscode.window.showInformationMessage(
'Hello, it is: ' + (new Date())
);
};
To start or stop jobs, press F1
, select Power Tools: Jobs
and choose the one, you would like to change its running state for.
Name | Description | Required? |
---|---|---|
action |
The action to invoke. | yes |
autoStart |
Run job on startup or not. Default: (true)
|
no |
button |
Settings for an optional button to start or stop the job. | no |
description 1
|
A description for the job. | no |
format 1
|
The format of time setting. Current supports: crontab . Default: crontab
|
no |
if |
(JavaScript) Code that checks if job is available or not. s. Conditional Settings | no |
importValues |
Defines a list of properties, which uses (external) values for itself. s. Import Settings | no |
name 1
|
The (display) name of the job. | no |
onCreated |
The (JavaScript) code to executed after job has been created. s. Executable Settings | no |
onDestroyed |
The (JavaScript) code to executed after job has been destroyed. s. Executable Settings | no |
platforms |
A list of one or more platform IDs, where the job should be available on. s. process.platform | no |
time 1
|
The (crontab) time. Default: 0 * * * * *
|
no |
1 supports placeholders
Name | Description | Required? |
---|---|---|
type |
The type. Current supports: script and shell . Default: shell
|
no |
Runs a Node.js based script file.
{
"ego.power-tools": {
"jobs": [
{
"name": "My job",
"description": "A job that runs all 30 seconds.",
"time": "*/30 * * * * *",
"action": {
"type": "script",
"script": "my_job.js",
"options": "<Any JavaScript object / value can be used>"
}
}
]
}
}
Name | Description | Required? |
---|---|---|
options |
Options for the script. | no |
script 1
|
The path to the script that should be invoked. Relative paths will be mapped to the .vscode sub folder of the workspace or the .vscode-powertools sub folder inside the current user's home directory. |
yes |
1 supports placeholders
Runs a shell command.
{
"ego.power-tools": {
"jobs": [
{
"name": "My job",
"description": "A job that runs a 'git fetch' all 30 minutes.",
"time": "0 */30 * * * *",
"action": {
"type": "shell",
"command": "git fetch"
}
}
]
}
}
Name | Description | Required? |
---|---|---|
command 1
|
The command that should be run. | yes |
cwd 1
|
The working directory. Relative paths will be mapped to the workspace root folder. Default: (workspace root folder) | no |
silent |
Do not write result to output. Default: (true)
|
no |
wait |
Wait until command has been executed or not. Default: (true)
|
no |
1 supports placeholders
Name | Description | Required? |
---|---|---|
color 1
|
The RGB text color. | no |
isRight |
Display button one the right side or not. Default: (false)
|
no |
priority |
A (numeric) value that defines the priority, the button should be displayed with. | no |
text 1 2
|
The (display) text. | no |
tooltip 1
|
The tooltip text. | no |
1 supports placeholders
2 supports icons
licensed under GDFL 1.3 - © Next.e.GO Mobile SE