Get relative path of the file for tasks in vscode(获取vscode中任务文件的相对路径)
问题描述
我在 vscode 的 tasks.json 文件中定义了一个任务,如下所示
<代码>{版本":0.1.0",任务": [{命令":吞咽","taskName": "eslint_task",参数":[埃斯林特","- 文件",${文件}"],回声命令":真}]}${file} 为我提供了运行此命令的文件的绝对路径(在 macOS 中从 /Volumes 开始).有什么方法可以获取同一文件的相对路径(从工作区文件夹开始的路径)?
我已经查看了任务的官方文档,但找不到任何那里的参数列表.
找到了答案.我只需要使用 ${relativeFile} 而不是 ${file}.
这是我找到的占位符列表 -
${workspaceRoot}:工作区根文件夹${file}:保存文件的路径${relativeFile}:保存文件的相对路径${fileBasename}:保存文件的基本名称${fileDirname}:保存文件的目录名${fileExtname}:保存文件的扩展名(包括.)${fileBasenameNoExt}:保存文件的基本名称,不带扩展名${cwd}:当前工作目录
来源:取自这里.p>
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.
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 directory
Source: Taken from here.
这篇关于获取vscode中任务文件的相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:获取vscode中任务文件的相对路径
基础教程推荐
- 如何在特定日期之前获取消息? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
