Skip to content

Commit

Permalink
Added csslinting to CSS files, errors are not pretty since no YUI cod…
Browse files Browse the repository at this point in the history
…e fails lint
  • Loading branch information
davglass committed Aug 28, 2012
1 parent af14467 commit d23f73c
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ var Stack = require('./stack').Stack,
lintFail = false,
metaFile = path.join(process.cwd(), '.shifter_meta'),
cacheBuild = false,
cssLint = {
callback: function (info) {
var file = info.name.replace(process.cwd(), ''),
lint = info.csslint;
if (lint.length) {
log.err(file + ' contains ' + lint.length + ' lint errors');
console.log(lint);
} else {
log.info('css lint passed for ' + file);
}
}
},
setJSLint = function () {
var i;
jslintConfig = {
Expand Down Expand Up @@ -60,7 +72,7 @@ var Stack = require('./stack').Stack,
}
items.forEach(function (file, key) {
var d = dir;
if (file.indexOf(d) === 0 || file.indexOf('./' + d) === 0) {
if (file.indexOf(d + '/') === 0 || file.indexOf('./' + d) === 0) {
d = '';
}
i[key] = path.join(process.cwd(), d, file);
Expand Down Expand Up @@ -129,9 +141,11 @@ var buildCSS = function (mod, name, callback) {
});

queue.read(resolve(mod.cssfiles, 'css'))
.concat()
.cssstamp({
stamp: '/* YUI CSS Detection Stamp */\n#yui3-css-stamp.' + name + ' { display: none; }'
})
.csslint(cssLint)
.write(path.join(buildDir, name, name + '.css'))
.compressor({
'line-break': 6000,
Expand Down Expand Up @@ -163,7 +177,7 @@ var buildJS = function (mod, name, callback) {

queue.read(resolve(mod.jsfiles, 'js'))
.concat();

if (mod.stamp) {
queue.jsstamp({
strict: strictMode,
Expand All @@ -173,9 +187,9 @@ var buildJS = function (mod, name, callback) {
}

queue.wrap({
prepend: resolve(mod.prependfiles, 'js'),
append: resolve(mod.appendfiles, 'js')
});
prepend: resolve(mod.prependfiles, 'js'),
append: resolve(mod.appendfiles, 'js')
});

if (mod.replace) {
Object.keys(mod.replace).forEach(function (key) {
Expand Down Expand Up @@ -318,18 +332,20 @@ var buildLang = function (mod, name, callback) {
exports.lang = buildLang;

var buildSkin = function (mod, name, callback) {
log.info('shifting skin for ' + name);

var stack = new Stack(),
queue = new Queue({
logger: log,
registry: registry
})
.read([path.join(process.cwd(), 'assets', name + '-core.css')])
.log('writing -core css skin file')
.write(path.join(buildDir, name, 'assets', name + '-core.css'))
.run(stack.add(function () {}));

//Get list of Skins
fs.readdir(path.join(process.cwd(), 'assets/skins'), function (err, skins) {
fs.readdir(path.join(process.cwd(), 'assets/skins'), stack.add(function (err, skins) {

//Walk the skins and write them out
skins.forEach(function (skinName) {
Expand All @@ -342,16 +358,19 @@ var buildSkin = function (mod, name, callback) {
Rqueue;

queue.read([
path.resolve(base, '../', name + '-core.css'),
path.resolve(base, '../../', name + '-core.css'),
path.join(base, name + '-skin.css')
])
.concat()
.csslint(cssLint)
.cssstamp({
stamp: '/* YUI CSS Detection Stamp */\n#yui3-css-stamp.skin-' + skinName + '-' + name + ' { display: none; }'
})
.compressor({
'line-break': 6000,
type: 'css'
})
.cssstamp({
stamp: '/* YUI CSS Detection Stamp */\n#yui3-css-stamp.skin-' + skinName + '-' + name + ' { display: none; }'
})
.log('writing skin file with core wrapper')
.write(path.join(buildDir, name, 'assets', 'skins', skinName, name + '.css'))
.run(stack.add(function () {
}));
Expand All @@ -364,13 +383,14 @@ var buildSkin = function (mod, name, callback) {
Rqueue.read([
path.join(base, name + '-skin.css')
])
.log('writing skin file without core wrapper')
.write(path.join(buildDir, name, 'assets', 'skins', skinName, name + '-skin.css'))
.run(stack.add(function () {
}));

});

});
}));

stack.done(callback);

Expand Down

0 comments on commit d23f73c

Please sign in to comment.