Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logos cleanup and AppVeyor #812

Merged
merged 3 commits into from
Apr 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/load-logos.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ var fs = require('fs');
var path = require('path');

var loadLogos = function() {
// Cache svg logos from disk in base64 string
var logos = {};
var logoFiles = fs.readdirSync(path.join(__dirname, '..', 'logo'));
var logoDir = path.join(__dirname, '..', 'logo');
var logoFiles = fs.readdirSync(logoDir);
logoFiles.forEach(function(filename) {
if (filename[0] === '.') { return; }
// filename is eg, github.svg
var svg = fs.readFileSync(
path.join(__dirname, '..', 'logo', filename)).toString();
var svg = fs.readFileSync(logoDir + '/' + filename).toString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use a call to path.join here? It works better across platforms.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my Windows it works okay, so I don't see why it is needed here. It probably matters if you have to call some external Windows program and pass the path there, which is not the case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the node internal functions handle either okay.

Copy link
Member

@espadrine espadrine Apr 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows internally supports forward slashes. The main purpose of path.join() in practice is path normalization, eg. path.join('foo/', '..', 'bar') === 'bar'.


// eg, github
var name = filename.slice(0, -('.svg'.length));
Expand Down
2 changes: 1 addition & 1 deletion logo/appveyor.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ cache(function(data, match, sendBadge, request) {
apiUrl += '/branch/' + branch;
}
var badgeData = getBadgeData('build', data);
badgeData.logo = badgeData.logo || logos['appveyor'];
request(apiUrl, { headers: { 'Accept': 'application/json' } }, function(err, res, buffer) {
if (err != null) {
badgeData.text[1] = 'inaccessible';
Expand Down