-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
101 lines (80 loc) · 2.52 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
'use strict';
var through = require('through2');
var fs = require('fs-extra');
var path = require('path');
module.exports = function () {
return through.obj(function (file, enc, cb) {
console.log(file);
cb(null, file);
}, function (cb) {
cb();
});
}
// module.exports = function (opts) {
// var errorCount = 0;
// var totalCount = 0;
// var fileText = '';
// var fileRef = {};
// var outputFile;
// if (opts && opts.output) {
// outputFile = opts.output;
// } else {
// outputFile = (process.cwd() + '/jscs.html');
// }
// function htmlEscape(str) {
// return String(str)
// .replace(/&/g, '&')
// .replace(/"/g, '"')
// .replace(/'/g, ''')
// .replace(/</g, '<')
// .replace(/>/g, '>');
// }
// return through.obj(function (file, enc, cb) {
// fileRef = file;
// if (file.jscs && !file.jscs.success) {
// var errors = file.jscs.errors;
// var errorList = errors.getErrorList();
// var fileName = errorList[0].filename;
// errorList.forEach(function () {
// errorCount++;
// totalCount++;
// });
// fileText += '\t\t<div class="block">\n';
// if (errorCount) {
// var str = '\t\t\t<input type="checkbox">\n\t\t\t<h2>' + (errorCount + ' code style ' + (errorCount === 1 ? 'error' : 'errors') + ' found in ' + fileName) + '</h2>\n';
// fileText += str;
// if (opts && opts.logToConsole) {
// console.log((errorCount + ' code style ' + (errorCount === 1 ? 'error' : 'errors') + ' found in ' + fileName));
// }
// errorCount = 0;
// }
// errorList.forEach(function (error) {
// var str = '\t\t\t<p>';
// var lines = errors.explainError(error).split('\n');
// if (opts && opts.logToConsole) {
// console.log(errors.explainError(error));
// }
// lines.forEach(function (line, i) {
// if (i === 0) {
// str += (htmlEscape(line) + '</p>\n\t\t\t<p class="code">');
// } else {
// str += (htmlEscape(line) + '<br>\n\t\t\t');
// }
// });
// str = str += '</p>\n';
// fileText += str;
// });
// fileText += '\t\t</div>\n';
// }
// cb(null, file);
// }, function (cb) {
// if (fileRef.jscs && !fileRef.jscs.success) {
// fs.ensureFileSync(outputFile);
// var results = fs.readFileSync(path.join(__dirname, '/html-template.html'), 'utf-8');
// results = results.replace('{{totalCount}}', totalCount).split('</body>')[0];
// results += (fileText + '\t\t</div>\n\t</body>\n</html>');
// fs.writeFileSync(outputFile, results);
// }
// cb();
// });
// };