-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
49 lines (35 loc) · 1.13 KB
/
app.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
var fs = require('fs');
var _ = require('underscore');
var $ = require('jquery');
var logNotFound = function (log) {
console.log('Logged missed selector: ', log);
}
var matchInMarkup = function (row, markup) {
var $markup = $(markup),
selectorPosition = row.length - 1,
$matched,
selector = '',
firstRun;
if (!$markup.find(row).length) {
logNotFound(row);
}
};
var findCssSelectors = function (styles, markup) {
var selectorRows = styles.replace(/\{/g, ' {').match(/.+\{/gim),
$markup = $(markup);
console.log('selectorRows: ', selectorRows);
_.each(selectorRows, function (row, index) {
row = row.replace(/ +/g, ' ' ).split(' ');
row = _.without(row, '{').join().replace(/,/g, ' ');
matchInMarkup(row, markup);
})
};
var markup = fs.readFileSync('testProject/index.html', 'utf-8');
var styles = fs.readFileSync('testProject/css/styles.css', 'utf-8');
// findCssSelectors(styles, markup);
/*
TODO:
Grab all the xsl files and consrtruct a pseudoDOMtree to check css rules against.
Grab all the css files and contrast them against the pseudoDOMtree.
*/
//var xslFolder = fs.readFileSync('/')