Skip to content

Commit e816f4f

Browse files
committed
Run grunt.
1 parent 823c30e commit e816f4f

File tree

7 files changed

+2348
-583
lines changed

7 files changed

+2348
-583
lines changed

dist/cli.js

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22
/*!
3-
CSSLint
4-
Copyright (c) 2014 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
3+
CSSLint v0.10.0
4+
Copyright (c) 2015 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
55
66
Permission is hereby granted, free of charge, to any person obtaining a copy
77
of this software and associated documentation files (the 'Software'), to deal
@@ -22,14 +22,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
THE SOFTWARE.
2323
2424
*/
25-
/* Build: v0.10.0 11-April-2014 12:11:52 *//*
25+
/*
2626
* Encapsulates all of the CLI functionality. The api argument simply
2727
* provides environment-specific functionality.
2828
*/
2929

30+
/* global JSON */
3031
/* exported cli */
3132

3233
function cli(api){
34+
"use strict";
3335

3436
var globalOptions = {
3537
"help" : { "format" : "", "description" : "Displays this information."},
@@ -40,6 +42,7 @@ function cli(api){
4042
"warnings" : { "format" : "<rule[,rule]+>", "description" : "Indicate which rules to include as warnings."},
4143
"ignore" : { "format" : "<rule[,rule]+>", "description" : "Indicate which rules to ignore completely."},
4244
"exclude-list": { "format" : "<file|dir[,file|dir]+>", "description" : "Indicate which files/directories to exclude from being linted."},
45+
"config" : { "format" : "<file>", "description" : "Reads csslint options from specified file."},
4346
"version" : { "format" : "", "description" : "Outputs the current version number."}
4447
};
4548

@@ -274,8 +277,9 @@ function cli(api){
274277
}
275278

276279

277-
function processArguments(args, options) {
280+
function processArguments(args, extend) {
278281
var arg = args.shift(),
282+
options = extend || {},
279283
argName,
280284
parts,
281285
files = [];
@@ -317,9 +321,16 @@ function cli(api){
317321
}
318322
}
319323

320-
function readConfigFile(options) {
321-
var data = api.readFile(api.getFullPath(".csslintrc")),
322-
json;
324+
function readConfigFile(config) {
325+
var csslintrc = config || ".csslintrc",
326+
data = api.readFile(api.getFullPath(csslintrc));
327+
return data;
328+
}
329+
330+
function readConfigData(config) {
331+
var data = readConfigFile(config),
332+
json,
333+
options = {};
323334
if (data) {
324335
if (data.charAt(0) === "{") {
325336
try {
@@ -332,46 +343,53 @@ function cli(api){
332343
}
333344
} catch(e) {}
334345
}
335-
options = processArguments(data.split(/[\s\n\r]+/m), options);
346+
options = processArguments(data.split(/[\s\n\r]+/m));
336347
}
337348

338349
return options;
339350
}
340351

341-
342-
343352
//-----------------------------------------------------------------------------
344353
// Process command line
345354
//-----------------------------------------------------------------------------
346355

347356
var args = api.args,
348357
argCount = args.length,
349-
options = {};
358+
options,
359+
rcOptions,
360+
cliOptions;
350361

351-
// first look for config file .csslintrc
352-
options = readConfigFile(options);
362+
// Preprocess command line arguments
363+
cliOptions = processArguments(args);
353364

354-
// Command line arguments override config file
355-
options = processArguments(args, options);
356-
357-
if (options.help || argCount === 0){
365+
if (cliOptions.help || argCount === 0){
358366
outputHelp();
359367
api.quit(0);
360368
}
361369

362-
// Validate options
363-
validateOptions(options);
364-
365-
if (options.version){
370+
if (cliOptions.version){
366371
api.print("v" + CSSLint.version);
367372
api.quit(0);
368373
}
369374

370-
if (options["list-rules"]){
375+
if (cliOptions["list-rules"]){
371376
printRules();
372377
api.quit(0);
373378
}
374379

380+
// Look for config file
381+
rcOptions = readConfigData(cliOptions.config);
382+
383+
// Command line arguments override config file
384+
options = CSSLint.Util.mix(rcOptions, cliOptions);
385+
386+
// hot fix for CSSLint.Util.mix current behavior
387+
// https://github.com/CSSLint/csslint/issues/501
388+
options = rcOptions;
389+
390+
// Validate options
391+
validateOptions(options);
392+
375393
api.quit(processFiles(options.files,options));
376394
}
377395

@@ -382,6 +400,7 @@ function cli(api){
382400
/* jshint node:true */
383401
/* global cli */
384402
/* exported CSSLint */
403+
"use strict";
385404

386405
var fs = require("fs"),
387406
path = require("path"),
@@ -421,7 +440,7 @@ cli({
421440
var path = stack.concat([file]).join("/"),
422441
stat = fs.statSync(path);
423442

424-
if (file[0] == ".") {
443+
if (file[0] === ".") {
425444
return;
426445
} else if (stat.isFile() && /\.css$/.test(file)){
427446
files.push(path);
@@ -453,4 +472,3 @@ cli({
453472
}
454473
}
455474
});
456-

0 commit comments

Comments
 (0)