Commit a054e824 authored by Eric Eastwood's avatar Eric Eastwood

Prettier codebase

parent 20607b61

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

/*jslint node: true */
"use strict";
'use strict';
var env = require('gitter-web-env');
env.installUncaughtExceptionHandler();
......
......@@ -13,7 +13,7 @@ function childProcessToPromise(executable, command) {
});
return new Promise(function(resolve, reject) {
command.on('close', function (code) {
command.on('close', function(code) {
removeOnExit();
if (code) {
reject(new Error(executable + ' exited with ' + code));
......@@ -35,8 +35,7 @@ function spawn(executable, args, env) {
stdio: 'inherit',
env: _.extend({}, process.env, env)
});
})
.then(function(command) {
}).then(function(command) {
return childProcessToPromise(executable, command);
});
}
......@@ -47,8 +46,7 @@ function fork(script, args, env) {
stdio: 'inherit',
env: _.extend({}, process.env, env)
});
})
.then(function(command) {
}).then(function(command) {
return childProcessToPromise(script, command);
});
}
......
......@@ -14,7 +14,7 @@ function filterFiles(baseBranch) {
var result = parse(diff);
var changedLines = {}
var changedLines = {};
result.forEach(function(file) {
var absPath = path.resolve(file.to);
var diffLine = 0;
......@@ -26,7 +26,7 @@ function filterFiles(baseBranch) {
changedLines[absPath][change.ln] = diffLine;
}
});
})
});
});
return resolve(changedLines);
......@@ -34,22 +34,23 @@ function filterFiles(baseBranch) {
});
return es.map(function(data, callback) {
changedPromise.then(function(changedLines) {
if (!changedLines[data.path]) return;
if (data.content) {
data.eslintFileChanges = changedLines[data.path];
return data;
}
changedPromise
.then(function(changedLines) {
if (!changedLines[data.path]) return;
if (data.content) {
data.eslintFileChanges = changedLines[data.path];
return data;
}
return vinylFile.read(data.path)
.then(function(data) {
return vinylFile.read(data.path).then(function(data) {
data.eslintFileChanges = changedLines[data.path];
return data;
});
}).then(function(result) {
return callback(null, result);
}, callback)
})
})
.then(function(result) {
return callback(null, result);
}, callback);
});
}
function filterMessages() {
......@@ -68,31 +69,34 @@ function filterMessages() {
});
eslintData.messages = messages;
var counts = messages.reduce(function(memo, message) {
switch(message.severity) {
case 1:
memo.warningCount++;
break;
var counts = messages.reduce(
function(memo, message) {
switch (message.severity) {
case 1:
memo.warningCount++;
break;
case 2:
memo.errorCount++;
break;
case 2:
memo.errorCount++;
break;
}
return memo;
},
{
errorCount: 0,
warningCount: 0
}
return memo;
}, {
errorCount: 0,
warningCount: 0
});
);
eslintData.errorCount = counts.errorCount;
eslintData.warningCount = counts.warningCount;
}
callback(null, data)
})
callback(null, data);
});
}
module.exports = {
filterFiles: filterFiles,
filterMessages: filterMessages
}
};
"use strict";
'use strict';
var postcss = require('postcss');
var fs = require('fs');
......@@ -11,11 +11,11 @@ function extractUrls(input, basePath) {
function getFileName(value) {
var u = url.parse(value);
if(u.protocol || u.hostname) return value;
if (u.protocol || u.hostname) return value;
value = u.pathname;
if(value.indexOf('.') === 0) {
if (value.indexOf('.') === 0) {
var inputRelativeDir = path.dirname(path.relative(basePath, input));
var relativeToPublicFilePath = path.join(inputRelativeDir, value);
return path.join('public', relativeToPublicFilePath);
......@@ -29,7 +29,7 @@ function extractUrls(input, basePath) {
css.eachDecl(function(decl) {
if (!decl.value) return;
if(decl.prop !== 'src' || decl.parent.name !== 'font-face') return;
if (decl.prop !== 'src' || decl.parent.name !== 'font-face') return;
if (!decl.parent.decls) return;
......@@ -37,7 +37,7 @@ function extractUrls(input, basePath) {
return d.prop === 'src' && d.parent.name === 'font-face';
});
if(!d.length) return;
if (!d.length) return;
// var hasTtf = d.filter(function(x) {
// return x.value.indexOf('.ttf') >= 0;
......@@ -46,7 +46,6 @@ function extractUrls(input, basePath) {
// if(hasTtf.length) {
// decl.parent.decls = hasTtf;
// }
});
css.eachDecl(function(decl) {
......@@ -54,22 +53,22 @@ function extractUrls(input, basePath) {
var urls = [];
reduceFunctionCall(decl.value, "url", function(value) {
reduceFunctionCall(decl.value, 'url', function(value) {
var m = /^['"]([^'"]*)['"]$/.exec(value);
if(m) value = m[1];
if (m) value = m[1];
value = getFileName(value);
urls.push(value);
});
if(decl.prop === 'src' && decl.parent.name === 'font-face') {
if (decl.prop === 'src' && decl.parent.name === 'font-face') {
// If there are multiple fonts, choose the ttf
var ttfs = urls.filter(function(v) {
return (/\.ttf/).test(v);
return /\.ttf/.test(v);
});
if(ttfs.length > 0) {
if (ttfs.length > 0) {
urls = ttfs;
}
}
......@@ -77,7 +76,6 @@ function extractUrls(input, basePath) {
urls.forEach(function(value) {
resources[value] = true;
});