Permalink
Browse files

Using __dirname

  • Loading branch information...
1 parent 48cf0cc commit 24f1bd6f0ff5deec9edd0dc26a0ca926a3002d7b @espadrine espadrine committed Jan 18, 2014
Showing with 10 additions and 7 deletions.
  1. +6 −4 badge.js
  2. +4 −3 gh-badge.js
View
10 badge.js
@@ -1,4 +1,5 @@
var fs = require('fs');
+var path = require('path');
var SVGO = require('svgo');
// Initialize what will be used for automatic text measurement.
@@ -7,15 +8,16 @@ var canvasElement = new Canvas(0, 0); // Width and height are irrelevant.
var canvasContext = canvasElement.getContext('2d');
var CanvasFont = Canvas.Font;
try {
- var opensans = new CanvasFont('Verdana', './Verdana.ttf');
+ var opensans = new CanvasFont('Verdana',
+ path.join(__dirname, 'Verdana.ttf'));
canvasContext.addFont(opensans);
} catch(e) {}
-canvasContext.font = '11px Verdana';
+canvasContext.font = '11px Verdana, "DejaVu Sans"';
// Template crafting action below.
var dot = require('dot');
-var colorscheme = require('./colorscheme.json');
-var template = fs.readFileSync('./template.svg');
+var colorscheme = require(path.join(__dirname, 'colorscheme.json'));
+var template = fs.readFileSync(path.join(__dirname, 'template.svg'));
var imageTemplate = dot.template(''+template);
function optimize(string, callback) {
View
7 gh-badge.js
@@ -1,6 +1,7 @@
-var badge = require('./badge.js');
-var svg2img = require('./svg-to-img.js');
-var colorscheme = require('./colorscheme.json');
+var path = require('path');
+var badge = require(path.join(__dirname, 'badge.js'));
+var svg2img = require(path.join(__dirname, 'svg-to-img.js'));
+var colorscheme = require(path.join(__dirname, 'colorscheme.json'));
if (process.argv.length < 4) {
console.log('Usage: badge subject status [:colorscheme] [.output]');
console.log('Or: badge subject status right-color [left-color] [.output]');

0 comments on commit 24f1bd6

Please sign in to comment.