ruby_css_lint 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +71 -0
- data/VERSION +1 -0
- data/csslint/CHANGELOG +286 -0
- data/csslint/LICENSE +20 -0
- data/csslint/README.md +25 -0
- data/csslint/build.xml +242 -0
- data/csslint/demos/CSSLintDemo.htm +105 -0
- data/csslint/demos/demo.css +43 -0
- data/csslint/lib/js.jar +0 -0
- data/csslint/lib/jshint.js +3963 -0
- data/csslint/lib/parserlib.js +6295 -0
- data/csslint/lib/yuitest-rhino-cli.js +3955 -0
- data/csslint/lib/yuitest.js +4561 -0
- data/csslint/npm/package.json +30 -0
- data/csslint/release/csslint-node.js +9125 -0
- data/csslint/release/csslint-rhino.js +9390 -0
- data/csslint/release/csslint-tests.js +1921 -0
- data/csslint/release/csslint-worker.js +9148 -0
- data/csslint/release/csslint-wsh.js +9477 -0
- data/csslint/release/csslint.js +9127 -0
- data/csslint/release/npm/cli.js +307 -0
- data/csslint/release/npm/lib/csslint-node.js +9125 -0
- data/csslint/release/npm/package.json +30 -0
- data/csslint/src/cli/common.js +215 -0
- data/csslint/src/cli/node.js +87 -0
- data/csslint/src/cli/rhino.js +47 -0
- data/csslint/src/cli/wsh.js +134 -0
- data/csslint/src/core/CSSLint.js +181 -0
- data/csslint/src/core/Reporter.js +161 -0
- data/csslint/src/core/Util.js +62 -0
- data/csslint/src/formatters/checkstyle-xml.js +109 -0
- data/csslint/src/formatters/compact.js +59 -0
- data/csslint/src/formatters/csslint-xml.js +68 -0
- data/csslint/src/formatters/lint-xml.js +69 -0
- data/csslint/src/formatters/text.js +64 -0
- data/csslint/src/rules/adjoining-classes.js +45 -0
- data/csslint/src/rules/box-model.js +93 -0
- data/csslint/src/rules/box-sizing.js +28 -0
- data/csslint/src/rules/compatible-vendor-prefixes.js +171 -0
- data/csslint/src/rules/display-property-grouping.js +117 -0
- data/csslint/src/rules/duplicate-background-images.js +37 -0
- data/csslint/src/rules/duplicate-properties.js +46 -0
- data/csslint/src/rules/empty-rules.js +34 -0
- data/csslint/src/rules/errors.js +23 -0
- data/csslint/src/rules/fallback-colors.js +67 -0
- data/csslint/src/rules/floats.js +36 -0
- data/csslint/src/rules/font-faces.js +30 -0
- data/csslint/src/rules/font-sizes.js +35 -0
- data/csslint/src/rules/gradients.js +69 -0
- data/csslint/src/rules/ids.js +50 -0
- data/csslint/src/rules/import.js +23 -0
- data/csslint/src/rules/important.js +37 -0
- data/csslint/src/rules/known-properties.js +29 -0
- data/csslint/src/rules/outline-none.js +73 -0
- data/csslint/src/rules/overqualified-elements.js +63 -0
- data/csslint/src/rules/qualified-headings.js +38 -0
- data/csslint/src/rules/regex-selectors.js +44 -0
- data/csslint/src/rules/rules-count.js +28 -0
- data/csslint/src/rules/shorthand.js +87 -0
- data/csslint/src/rules/star-property-hack.js +27 -0
- data/csslint/src/rules/text-indent.js +53 -0
- data/csslint/src/rules/underscore-property-hack.js +27 -0
- data/csslint/src/rules/unique-headings.js +74 -0
- data/csslint/src/rules/universal-selector.js +35 -0
- data/csslint/src/rules/unqualified-attributes.js +42 -0
- data/csslint/src/rules/vendor-prefix.js +143 -0
- data/csslint/src/rules/zero-units.js +34 -0
- data/csslint/src/worker/Worker.js +26 -0
- data/csslint/tests/all-rules.js +64 -0
- data/csslint/tests/core/CSSLint.js +22 -0
- data/csslint/tests/core/Reporter.js +36 -0
- data/csslint/tests/css/width-100.html +76 -0
- data/csslint/tests/formatters/checkstyle-xml.js +44 -0
- data/csslint/tests/formatters/compact.js +47 -0
- data/csslint/tests/formatters/csslint-xml.js +42 -0
- data/csslint/tests/formatters/lint-xml.js +43 -0
- data/csslint/tests/formatters/text.js +36 -0
- data/csslint/tests/rules/adjoining-classes.js +31 -0
- data/csslint/tests/rules/box-model.js +211 -0
- data/csslint/tests/rules/box-sizing.js +23 -0
- data/csslint/tests/rules/compatible-vendor-prefixes.js +56 -0
- data/csslint/tests/rules/display-property-grouping.js +213 -0
- data/csslint/tests/rules/duplicate-background-images.js +25 -0
- data/csslint/tests/rules/duplicate-properties.js +54 -0
- data/csslint/tests/rules/empty-rules.js +18 -0
- data/csslint/tests/rules/errors.js +17 -0
- data/csslint/tests/rules/fallback-colors.js +162 -0
- data/csslint/tests/rules/floats.js +35 -0
- data/csslint/tests/rules/font-faces.js +28 -0
- data/csslint/tests/rules/font-sizes.js +30 -0
- data/csslint/tests/rules/gradients.js +60 -0
- data/csslint/tests/rules/ids.js +25 -0
- data/csslint/tests/rules/import.js +18 -0
- data/csslint/tests/rules/important.js +27 -0
- data/csslint/tests/rules/known-properties.js +44 -0
- data/csslint/tests/rules/outline-none.js +50 -0
- data/csslint/tests/rules/overqualified-elements.js +41 -0
- data/csslint/tests/rules/qualified-headings.js +19 -0
- data/csslint/tests/rules/regex-selectors.js +52 -0
- data/csslint/tests/rules/shorthand.js +36 -0
- data/csslint/tests/rules/star-property-hack.js +24 -0
- data/csslint/tests/rules/text-indent.js +55 -0
- data/csslint/tests/rules/underscore-property-hack.js +24 -0
- data/csslint/tests/rules/unique-headings.js +47 -0
- data/csslint/tests/rules/universal-selector.js +31 -0
- data/csslint/tests/rules/unqualified-attributes.js +37 -0
- data/csslint/tests/rules/vendor-prefix.js +76 -0
- data/csslint/tests/rules/zero-units.js +44 -0
- data/csslint/tests/testrunner.htm +138 -0
- data/js.jar +0 -0
- data/lib/ruby_css_lint.rb +168 -0
- data/test/helper.rb +17 -0
- data/test/test_ruby_css_lint.rb +7 -0
- metadata +240 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "csslint",
|
|
3
|
+
"version": "0.9.8",
|
|
4
|
+
"description": "CSSLint",
|
|
5
|
+
"author": "Nicholas C. Zakas",
|
|
6
|
+
"os": ["darwin", "linux", "win32"],
|
|
7
|
+
"contributors": [
|
|
8
|
+
"Nicole Sullivan"
|
|
9
|
+
],
|
|
10
|
+
"engines": {
|
|
11
|
+
"node" : ">=0.2.0"
|
|
12
|
+
},
|
|
13
|
+
"directories": {
|
|
14
|
+
"lib" : "lib"
|
|
15
|
+
},
|
|
16
|
+
"main": "./lib/csslint-node.js",
|
|
17
|
+
"bin": {
|
|
18
|
+
"csslint": "./cli.js"
|
|
19
|
+
},
|
|
20
|
+
"licenses":[
|
|
21
|
+
{
|
|
22
|
+
"type" : "MIT",
|
|
23
|
+
"url" : "https://github.com/stubbornella/csslint/blame/master/LICENSE"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"repository": {
|
|
27
|
+
"type":"git",
|
|
28
|
+
"url":"http://github.com/stubbornella/csslint.git"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Encapsulates all of the CLI functionality. The api argument simply
|
|
3
|
+
* provides environment-specific functionality.
|
|
4
|
+
*/
|
|
5
|
+
/*global CSSLint*/
|
|
6
|
+
function cli(api){
|
|
7
|
+
|
|
8
|
+
//-------------------------------------------------------------------------
|
|
9
|
+
// Helper functions
|
|
10
|
+
//-------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Returns an array of messages for a particular type.
|
|
14
|
+
* @param messages {Array} Array of CSS Lint messages.
|
|
15
|
+
* @param type {String} The type of message to filter on.
|
|
16
|
+
* @return {Array} An array of matching messages.
|
|
17
|
+
*/
|
|
18
|
+
function pluckByType(messages, type){
|
|
19
|
+
return messages.filter(function(message) {
|
|
20
|
+
return message.type === type;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Returns a ruleset object based on the CLI options.
|
|
26
|
+
* @param options {Object} The CLI options.
|
|
27
|
+
* @return {Object} A ruleset object.
|
|
28
|
+
*/
|
|
29
|
+
function gatherRules(options){
|
|
30
|
+
var ruleset,
|
|
31
|
+
warnings = options.rules || options.warnings,
|
|
32
|
+
errors = options.errors;
|
|
33
|
+
|
|
34
|
+
if (warnings){
|
|
35
|
+
ruleset = ruleset || {};
|
|
36
|
+
warnings.split(",").forEach(function(value){
|
|
37
|
+
ruleset[value] = 1;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (errors){
|
|
42
|
+
ruleset = ruleset || {};
|
|
43
|
+
errors.split(",").forEach(function(value){
|
|
44
|
+
ruleset[value] = 2;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return ruleset;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Outputs all available rules to the CLI.
|
|
53
|
+
* @return {void}
|
|
54
|
+
*/
|
|
55
|
+
function printRules(){
|
|
56
|
+
api.print("");
|
|
57
|
+
var rules = CSSLint.getRules();
|
|
58
|
+
rules.forEach(function(rule){
|
|
59
|
+
api.print(rule.id + "\n " + rule.desc + "\n");
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Given a file name and options, run verification and print formatted output.
|
|
65
|
+
* @param {String} relativeFilePath absolute file location
|
|
66
|
+
* @param {Object} options for processing
|
|
67
|
+
* @return {Number} exit code
|
|
68
|
+
*/
|
|
69
|
+
function processFile(relativeFilePath, options) {
|
|
70
|
+
var input = api.readFile(relativeFilePath),
|
|
71
|
+
result = CSSLint.verify(input, gatherRules(options)),
|
|
72
|
+
formatter = CSSLint.getFormatter(options.format || "text"),
|
|
73
|
+
messages = result.messages || [],
|
|
74
|
+
output,
|
|
75
|
+
exitCode = 0;
|
|
76
|
+
|
|
77
|
+
if (!input) {
|
|
78
|
+
if (formatter.readError) {
|
|
79
|
+
api.print(formatter.readError(relativeFilePath, "Could not read file data. Is the file empty?"));
|
|
80
|
+
} else {
|
|
81
|
+
api.print("csslint: Could not read file data in " + relativeFilePath + ". Is the file empty?");
|
|
82
|
+
}
|
|
83
|
+
exitCode = 1;
|
|
84
|
+
} else {
|
|
85
|
+
//var relativeFilePath = getRelativePath(api.getWorkingDirectory(), fullFilePath);
|
|
86
|
+
options.fullPath = api.getFullPath(relativeFilePath);
|
|
87
|
+
output = formatter.formatResults(result, relativeFilePath, options);
|
|
88
|
+
if (output){
|
|
89
|
+
api.print(output);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (messages.length > 0 && pluckByType(messages, "error").length > 0) {
|
|
93
|
+
exitCode = 1;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return exitCode;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Outputs the help screen to the CLI.
|
|
103
|
+
* @return {void}
|
|
104
|
+
*/
|
|
105
|
+
function outputHelp(){
|
|
106
|
+
api.print([
|
|
107
|
+
"\nUsage: csslint-rhino.js [options]* [file|dir]*",
|
|
108
|
+
" ",
|
|
109
|
+
"Global Options",
|
|
110
|
+
" --help Displays this information.",
|
|
111
|
+
" --format=<format> Indicate which format to use for output.",
|
|
112
|
+
" --list-rules Outputs all of the rules available.",
|
|
113
|
+
" --quiet Only output when errors are present.",
|
|
114
|
+
" --errors=<rule[,rule]+> Indicate which rules to include as errors.",
|
|
115
|
+
" --warnings=<rule[,rule]+> Indicate which rules to include as warnings.",
|
|
116
|
+
" --version Outputs the current version number."
|
|
117
|
+
].join("\n") + "\n");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Given an Array of filenames, print wrapping output and process them.
|
|
122
|
+
* @param files {Array} filenames list
|
|
123
|
+
* @param options {Object} options object
|
|
124
|
+
* @return {Number} exit code
|
|
125
|
+
*/
|
|
126
|
+
function processFiles(files, options){
|
|
127
|
+
var exitCode = 0,
|
|
128
|
+
formatId = options.format || "text",
|
|
129
|
+
formatter,
|
|
130
|
+
output;
|
|
131
|
+
|
|
132
|
+
if (!files.length) {
|
|
133
|
+
api.print("csslint: No files specified.");
|
|
134
|
+
exitCode = 1;
|
|
135
|
+
} else {
|
|
136
|
+
if (!CSSLint.hasFormat(formatId)){
|
|
137
|
+
api.print("csslint: Unknown format '" + formatId + "'. Cannot proceed.");
|
|
138
|
+
exitCode = 1;
|
|
139
|
+
} else {
|
|
140
|
+
formatter = CSSLint.getFormatter(formatId);
|
|
141
|
+
|
|
142
|
+
output = formatter.startFormat();
|
|
143
|
+
if (output){
|
|
144
|
+
api.print(output);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
files.forEach(function(file){
|
|
148
|
+
if (exitCode === 0) {
|
|
149
|
+
exitCode = processFile(file,options);
|
|
150
|
+
} else {
|
|
151
|
+
processFile(file,options);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
output = formatter.endFormat();
|
|
156
|
+
if (output){
|
|
157
|
+
api.print(output);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return exitCode;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
//-----------------------------------------------------------------------------
|
|
165
|
+
// Process command line
|
|
166
|
+
//-----------------------------------------------------------------------------
|
|
167
|
+
|
|
168
|
+
var args = api.args,
|
|
169
|
+
argName,
|
|
170
|
+
parts,
|
|
171
|
+
arg = args.shift(),
|
|
172
|
+
options = {},
|
|
173
|
+
files = [];
|
|
174
|
+
|
|
175
|
+
while(arg){
|
|
176
|
+
if (arg.indexOf("--") === 0){
|
|
177
|
+
argName = arg.substring(2);
|
|
178
|
+
options[argName] = true;
|
|
179
|
+
|
|
180
|
+
if (argName.indexOf("=") > -1){
|
|
181
|
+
parts = argName.split("=");
|
|
182
|
+
options[parts[0]] = parts[1];
|
|
183
|
+
} else {
|
|
184
|
+
options[argName] = true;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
} else {
|
|
188
|
+
|
|
189
|
+
//see if it's a directory or a file
|
|
190
|
+
if (api.isDirectory(arg)){
|
|
191
|
+
files = files.concat(api.getFiles(arg));
|
|
192
|
+
} else {
|
|
193
|
+
files.push(arg);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
arg = args.shift();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (options.help || arguments.length === 0){
|
|
200
|
+
outputHelp();
|
|
201
|
+
api.quit(0);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (options.version){
|
|
205
|
+
api.print("v" + CSSLint.version);
|
|
206
|
+
api.quit(0);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (options["list-rules"]){
|
|
210
|
+
printRules();
|
|
211
|
+
api.quit(0);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
api.quit(processFiles(files,options));
|
|
215
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* CSSLint Node.js Command Line Interface
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/*jshint node:true*/
|
|
6
|
+
/*global cli*/
|
|
7
|
+
|
|
8
|
+
var fs = require("fs"),
|
|
9
|
+
path = require("path"),
|
|
10
|
+
CSSLint = require("./lib/csslint-node").CSSLint;
|
|
11
|
+
|
|
12
|
+
cli({
|
|
13
|
+
args: process.argv.slice(2),
|
|
14
|
+
|
|
15
|
+
print: function(message){
|
|
16
|
+
fs.writeSync(1, message + "\n");
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
quit: function(code){
|
|
20
|
+
|
|
21
|
+
//Workaround for https://github.com/joyent/node/issues/1669
|
|
22
|
+
|
|
23
|
+
if ((!process.stdout.flush || !process.stdout.flush()) && (parseFloat(process.versions.node) < 0.5)) {
|
|
24
|
+
process.once("drain", function () {
|
|
25
|
+
process.exit(code || 0);
|
|
26
|
+
});
|
|
27
|
+
} else {
|
|
28
|
+
process.exit(code || 0);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
isDirectory: function(name){
|
|
33
|
+
try {
|
|
34
|
+
return fs.statSync(name).isDirectory();
|
|
35
|
+
} catch (ex) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
getFiles: function(dir){
|
|
41
|
+
var files = [];
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
fs.statSync(dir);
|
|
45
|
+
} catch (ex){
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function traverse(dir, stack){
|
|
50
|
+
stack.push(dir);
|
|
51
|
+
fs.readdirSync(stack.join("/")).forEach(function(file){
|
|
52
|
+
var path = stack.concat([file]).join("/"),
|
|
53
|
+
stat = fs.statSync(path);
|
|
54
|
+
|
|
55
|
+
if (file[0] == ".") {
|
|
56
|
+
return;
|
|
57
|
+
} else if (stat.isFile() && /\.css$/.test(file)){
|
|
58
|
+
files.push(path);
|
|
59
|
+
} else if (stat.isDirectory()){
|
|
60
|
+
traverse(file, stack);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
stack.pop();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
traverse(dir, []);
|
|
67
|
+
|
|
68
|
+
return files;
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
getWorkingDirectory: function() {
|
|
72
|
+
return process.cwd();
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
getFullPath: function(filename){
|
|
76
|
+
return path.resolve(process.cwd(), filename);
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
readFile: function(filename){
|
|
80
|
+
try {
|
|
81
|
+
return fs.readFileSync(filename, "utf-8");
|
|
82
|
+
} catch (ex) {
|
|
83
|
+
return "";
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* CSSLint Rhino Command Line Interface
|
|
3
|
+
*/
|
|
4
|
+
/*jshint rhino:true*/
|
|
5
|
+
/*global cli, File*/
|
|
6
|
+
|
|
7
|
+
importPackage(java.io);
|
|
8
|
+
|
|
9
|
+
cli({
|
|
10
|
+
args: arguments,
|
|
11
|
+
print: print,
|
|
12
|
+
quit: quit,
|
|
13
|
+
|
|
14
|
+
isDirectory: function(name){
|
|
15
|
+
var dir = new File(name);
|
|
16
|
+
return dir.isDirectory();
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
getFiles: function(dir){
|
|
20
|
+
var files = [];
|
|
21
|
+
|
|
22
|
+
function traverse(dir) {
|
|
23
|
+
var dirList = dir.listFiles();
|
|
24
|
+
dirList.forEach(function (file) {
|
|
25
|
+
if (/\.css$/.test(file)) {
|
|
26
|
+
files.push(file.toString());
|
|
27
|
+
} else if (file.isDirectory()) {
|
|
28
|
+
traverse(file);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
traverse(new File(dir));
|
|
34
|
+
|
|
35
|
+
return files;
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
getWorkingDirectory: function() {
|
|
39
|
+
return (new File(".")).getCanonicalPath();
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
getFullPath: function(filename){
|
|
43
|
+
return (new File(filename)).getCanonicalPath();
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
readFile: readFile
|
|
47
|
+
});
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Windows Script Host Command Line Interface
|
|
3
|
+
*/
|
|
4
|
+
/*global ActiveXObject, WScript, Enumerator, cli*/
|
|
5
|
+
//TODO: This file needs major cleanup!!!
|
|
6
|
+
|
|
7
|
+
var wshapi = (function(){
|
|
8
|
+
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
|
9
|
+
var shell = WScript.CreateObject("WScript.Shell");
|
|
10
|
+
var finalArgs = [], i, args = WScript.Arguments;
|
|
11
|
+
|
|
12
|
+
if (typeof Array.prototype.forEach !== "function") {
|
|
13
|
+
Array.prototype.forEach = function(f,m) {
|
|
14
|
+
for (var i=0, L=this.length; i<L; ++i) {
|
|
15
|
+
f(this[i], i, m);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (typeof Array.prototype.filter !== "function") {
|
|
21
|
+
Array.prototype.filter = function(fn /*, thisp*/) {
|
|
22
|
+
if (typeof fn != "function") {
|
|
23
|
+
throw new Error("not a function");
|
|
24
|
+
}
|
|
25
|
+
var res = [], val, thisp = finalArgs[1];
|
|
26
|
+
for (var i = 0, L = this.length; i < L; i++) {
|
|
27
|
+
if (i in this) {
|
|
28
|
+
val = this[i]; // in case fun mutates this
|
|
29
|
+
if (fn.call(thisp, val, i, this)){
|
|
30
|
+
res.push(val);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return res;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!Array.prototype.indexOf) {
|
|
40
|
+
Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
|
|
41
|
+
"use strict";
|
|
42
|
+
if (this === void 0 || this === null) {
|
|
43
|
+
throw new Error("unknown instance");
|
|
44
|
+
}
|
|
45
|
+
var t = this;
|
|
46
|
+
var len = t.length >>> 0;
|
|
47
|
+
if (len === 0) {
|
|
48
|
+
return -1;
|
|
49
|
+
}
|
|
50
|
+
var n = 0;
|
|
51
|
+
if (finalArgs.length > 0) {
|
|
52
|
+
n = Number(finalArgs[1]);
|
|
53
|
+
if (n !== n) { // shortcut for verifying if it's NaN
|
|
54
|
+
n = 0;
|
|
55
|
+
} else if (n !== 0 && n !== Infinity && n !== -Infinity) {
|
|
56
|
+
n = (n > 0 || -1) * Math.floor(Math.abs(n));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (n >= len) {
|
|
60
|
+
return -1;
|
|
61
|
+
}
|
|
62
|
+
var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0);
|
|
63
|
+
for (; k < len; k++) {
|
|
64
|
+
if (k in t && t[k] === searchElement) {
|
|
65
|
+
return k;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return -1;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function traverseDir(files, path) {
|
|
73
|
+
var filename, folder = fso.GetFolder(path),
|
|
74
|
+
subFlds, fc = new Enumerator(folder.files);
|
|
75
|
+
|
|
76
|
+
for (; !fc.atEnd(); fc.moveNext()) {
|
|
77
|
+
filename = fc.item();
|
|
78
|
+
if (/\.css$/.test(filename)) {
|
|
79
|
+
files.push(filename);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
subFlds = new Enumerator(folder.SubFolders);
|
|
84
|
+
for (; !subFlds.atEnd(); subFlds.moveNext()) {
|
|
85
|
+
traverseDir(files, subFlds.item());
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// turn the WScript.Arguments thing into a regular array
|
|
90
|
+
if (args.Length > 0) {
|
|
91
|
+
for (i = 0; i < args.Length; i++) {
|
|
92
|
+
finalArgs.push(args(i));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
args: finalArgs,
|
|
98
|
+
print: function(s) { WScript.Echo(s);},
|
|
99
|
+
quit: function (v) { WScript.Quit(v);},
|
|
100
|
+
|
|
101
|
+
isDirectory: function(name){
|
|
102
|
+
return fso.FolderExists(name);
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
getFiles: function(dir){
|
|
106
|
+
var files = [];
|
|
107
|
+
traverseDir(files, dir);
|
|
108
|
+
return files;
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
fixFilenames: function(files){
|
|
112
|
+
return files;
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
getWorkingDirectory: function() {
|
|
116
|
+
return shell.CurrentDirectory;
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
getFullPath: function(filename){
|
|
120
|
+
return fso.GetAbsolutePathName(filename);
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
readFile: function(path){
|
|
124
|
+
var forReading = 1;
|
|
125
|
+
var tf = fso.OpenTextFile(path, forReading);
|
|
126
|
+
var allText = tf.ReadAll();
|
|
127
|
+
tf.Close();
|
|
128
|
+
return allText;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
}());
|
|
133
|
+
|
|
134
|
+
cli(wshapi);
|