[英]How to use CSSLint?
I found some command line arguments to run generate the CSSLint report in xml format. 我发现一些命令行参数可以运行以xml格式生成CSSLint报告。 It is working fine while running through command prompt. 通过命令提示符运行时,它工作正常。
Arguments: 参数:
csslint --format=csslint-xml "{SourceDir}\\bootstrap.css" > "C:\\temp\\csslint.xml" csslint --format = csslint-xml“ {SourceDir} \\ bootstrap.css”>“ C:\\ temp \\ csslint.xml”
I want to execute it through C# application. 我想通过C#应用程序执行它。 I tried the below code. 我尝试了以下代码。
Process process = new Process()
{
StartInfo =
{
FileName = "cmd.exe",
Arguments = "csslint --format=csslint-xml " + @"""{SourceDir}\bootstrap.css""" + @" > ""C:\Temp\CssLint.xml""",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true,
}
};
process.Start();
process.WaitForExit();
But it is not working. 但这是行不通的。 Can i have a solution or idea for this issue? 我可以对此问题有解决方案或想法吗?
Also is there any way to generate the CSSLint report for the specified directory? 还有什么方法可以为指定目录生成CSSLint报告? I want to give the directory path instead of file name. 我想提供目录路径而不是文件名。
You need to add /K
or /C
to cmd
to execute a process passed as a parameter, thus: 您需要向cmd
添加/K
或/C
来执行作为参数传递的进程,因此:
Arguments = "/C csslint --format=csslint-xml " + @"""{SourceDir}\bootstrap.css""" + @" > ""C:\Temp\CssLint.xml""",
From the documentation : 从文档中 :
Options 选件
/C Run Command and then terminate / C运行命令,然后终止
/K Run Command and then return to the CMD prompt. / K运行命令,然后返回到CMD提示符。 This is useful for testing, to examine variables 这对于测试,检查变量很有用
One caveat... the piping (the > "C:\\temp\\csslint.xml"
part of your command line) is not an argument, it's a redirection. 请注意,管道(命令行的> "C:\\temp\\csslint.xml"
部分)不是参数,而是重定向。
If you are redirecting your stdout (the RedirectStandardOutput = true
) from your app, you can capture it directly from C#, no need to pipe it to a file like you are trying to do: you'd need to handle the Process.OutputDataReceived
event between your Start
and WaitForExit
calls, or read from the Process.StandardOutput
stream). 如果您要从应用程序重定向标准输出( RedirectStandardOutput = true
),则可以直接从C#捕获它,而无需像尝试做的那样将其通过管道传输到文件中:您需要处理Process.OutputDataReceived
事件在您的Start
和WaitForExit
调用之间,或者从Process.StandardOutput
流中读取)。
As for your second question, the csslint
CLI allows passing in a directory instead of a file 至于第二个问题, csslint
CLI允许传入目录而不是文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.