简体   繁体   English

在Node CLI中使用CSSLint

[英]Using CSSLint in Node cli

I am writing Node cli application which will run locally installed CSSLint module by passing parameters. 我正在编写Node cli应用程序,该应用程序将通过传递参数来运行本地安装的CSSLint模块。 The CSSLint application is started from function cli which is in cli.js file ( https://github.com/CSSLint/csslint/blob/master/dist/cli.js ). CSSLint应用程序从cli.js文件( https://github.com/CSSLint/csslint/blob/master/dist/cli.js )中的函数cli启动。 How can I include this file and call cli function? 如何包含此文件并调用cli函数?

What I have tried. 我尝试过的。

  1. I have tried adding statement var csslint = require('csslint/dist/cli.js') but this just executes the CSSLint and I am able to pass parameters 我试过添加语句var csslint = require('csslint / dist / cli.js'),但这只是执行CSSLint并且我能够传递参数

According to the documentation , if you y need to call CSSLint from your node application/script, you have to do the following: 根据文档 ,如果您需要从节点应用程序/脚本中调用CSSLint ,则必须执行以下操作:

var CSSLint = require('csslint').CSSLint;
var result = CSSLint.verify("h1 { color: red; }");
result.messages.forEach(function (message) {
    console.log("%s (line %d, col %d): %s", message.type, message.line, message.col, message.message);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM