Your search found these items:
Your search did not match any articles.
Variables & Expressions
When running tasks and resolving the arguments to provide, the IDE has the ability to evaluate certain strings against a set of built-in variables and expressions, allowing some options to be specified using knowledge only available at runtime.
These are the primary set of variables available to all evaluation contexts:
$WorkspaceName: The name of the current workspace
$WorkspaceFolder: The full (absolute) path of the workspace, if any
$WorkspaceFolderBasename: The folder name of the workspace, if any (which may be different than the workspace name)
$WorkingDirname: The current working directory of the task being executed (effectively the same as
cwdin a shell)
$File: The full (absolute) path of the currently focused file editor, if any
$FileRelative: The relative path of the currently focused file editor against the workspace folder, if any
$FileBasename: The filename of the currently focused file editor, if any
$FileDirname: The full (absolute) path of the folder containing the currently focused file editor, if any
$FileExtname: The file extension of the currently focused file editor, if any
$LineNumber: The line number containing the primary cursor within the currently focused file editor, if any
$SelectedText: The primary selected text within the the currently focused file editor, if any
String substitution may reference values stored in the user’s global and project configuration using an expression of the form
my.config-key is a key for a configuration item. Expressions of this form will check the most specific configuration available first, falling back if no value is found.
The order of precedence for configurations is:
- The configuration for the task being executed (such as a Task Template)
- The project configuration
- The user’s global configuration
If no value is found within a configuration, the default will be returned (if one is defined) before moving on to the next context. If no value is found, an empty string will be substituted.
For more complex handling of substitution, an extension Command may be invoked. This command need not be defined in an extension’s visible
commands object in its
extension.json file, it only needs to be registered with the extension’s CommandsRegistry.
Commands may be invoked by using an expression of the form
my.command-name is the name of the command used to register with the
nova.commands.add() of the commands registry. The command will then be invoked asynchronously by the extension runtime. If it returns a
Promise object, the runtime will wait for the promise to resolve before peforming the string substitution, unless the task requesting it is cancelled before the promise resolves.