我在 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 directorySource: Taken from here.
这篇关于获取vscode中任务文件的相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
Browserify,Babel 6,Gulp - 传播运算符上的意外令牌Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 传播运算符上的意外令牌)
是否可以将标志传递给 Gulp 以使其以不同的方式Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以将标志传递给 Gulp 以使其以不同的方式运行任务
为什么我们需要在全局和本地安装 gulp?Why do we need to install gulp globally and locally?(为什么我们需要在全局和本地安装 gulp?)
如何一个接一个地依次运行 Gulp 任务How to run Gulp tasks sequentially one after the other(如何一个接一个地依次运行 Gulp 任务)
打开 Javascript 文件时 Visual Studio 2015 崩溃Visual Studio 2015 crashes when opening Javascript files(打开 Javascript 文件时 Visual Studio 2015 崩溃)
检测 FLASH 插件崩溃Detect FLASH plugin crashes(检测 FLASH 插件崩溃)