-
Notifications
You must be signed in to change notification settings - Fork 9
Executable Settings
Settings, like if, execute JavaScript code, the time, when they are handled.
The following example, runs a npm install
on startup, only if node_modules
folder does not exist.
{
"ego.power-tools": {
"startup": [
{
"command": "npm install",
"if": " !$fs.existsSync( $v['workspaceRoot'] + '/node_modules' ) "
}
]
}
}
Keep in mind: Any code needs to be executed synchronously and does NOT support async patterns, like Promises!
For settings like apps, buttons, commands, events and jobs, you can define the onCreated
and/or onDestroyed
settings, which execute code, after an item has been created or destroyed:
{
"ego.power-tools": {
"buttons": [
{
"text": "Button 1",
"action": {
"type": "script",
"script": "mybutton.js"
},
"if": " !$s['mybutton'] ",
"onCreated": " $s['mybutton'] = true ",
"onDestroyed": " delete $s['mybutton'] "
},
{
"text": "Button 2 (will not be created)",
"action": {
"type": "script",
"script": "mybutton.js"
},
"if": " !$s['mybutton'] ",
"onCreated": " $s['mybutton'] = true ",
"onDestroyed": " delete $s['mybutton'] "
}
]
}
}
The (JavaScript) code to executed after active editor has changed.
That event is available for buttons and command buttons.
{
"ego.power-tools": {
"buttons": [
{
"text": "Button: ${activeFile}",
"action": {
"type": "script",
"script": "mybutton.js"
},
"onEditorChanged": " $v['button'].update() "
}
]
}
}
The event provides an additional value, called button
, which can be accessed via $v and implements the CodeButton interface.
The current session storage, which is available while the extension is running.
All available values as key/value pair.
!$fs.existsSync( $v['workspaceRoot'] + '/node_modules' )
Can (also) access any module of that extension.
$r('moment')().format('YYYY-MM-DD') === '1979-09-05'
Name | Description |
---|---|
_ |
lodash |
$fs |
fs-extra |
$h |
vscode-helpers |
$m |
Moment.js with timezone support |
$p |
Node.js path module |
$vs |
Visual Studio Code API |
licensed under GDFL 1.3 - © Next.e.GO Mobile SE