Reputation: 20348
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.
Upvotes: 14
Views: 10923
Reputation: 20348
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.
Upvotes: 26