I have a task defined in vscode's tasks.json file as following
{
"version": "0.1.0",
"tasks": [
{
"command": "gulp",
"taskName": "eslint_task",
"args": [
"eslint",
"--file",
"${file}"
],
"echoCommand": true
}
]
}
The ${file}
is providing me the absolute path (starting from /Volumes
in macOS) of the file on which I run this command. Is there any way I can get the relative path (Path starting from the workspace folder) of the same file instead?
I already checked the official documentation for tasks, but couldn't find any list of arguments there.
Press Ctrl+Shift+H (Mac: Cmd+Shift+H ) and start typing the file you want. 🪄 Select your file from the dropdown!
Using ctrl+P (or cmd+P) is however an easy way to do this. Simply put /myfolder or folder/file or even folder/*/file . You'll see files contained by that folder and the full path so.. like finding the folder.
You need to configure the tasks in a tasks. json file (located under your workspace . vscode folder) if you want to do more than simply run the task. For example, you might want to match reported problems and highlight them within VS Code, or to trigger a build task using the Run Build Task command ( kb(workbench.
Visual Studio Code plugin that autocompletes filenames.
Found the answer. I just need to use ${relativeFile}
instead of ${file}
.
Here's the list of placeholder I have found -
${workspaceRoot}
: workspace root folder${file}
: path of saved file${relativeFile}
: relative path of saved file ${fileBasename}
: saved file's basename ${fileDirname}
: directory name of saved file${fileExtname}
: extension (including .) of saved file${fileBasenameNoExt}
: saved file's basename without extension ${cwd}
:current working directorySource: Taken from here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With