Permalink
Browse files

Check for the compiled bindings in both places.

When node switched it's build system to GYP then the resulting bin
will be put in "Release" instead of "build". So check for both places with a
little `bindings.js` shim.
  • Loading branch information...
TooTallNate committed Oct 29, 2011
1 parent ff29b04 commit 42fce70a896a046b201c04a8a4921303acb876aa
Showing with 16 additions and 6 deletions.
  1. +10 −0 lib/bindings.js
  2. +1 −1 lib/canvas.js
  3. +2 −2 lib/context2d.js
  4. +2 −2 lib/image.js
  5. +1 −1 lib/pixelarray.js
View
@@ -0,0 +1,10 @@
+/**
+ * Compat for changes from node 0.4.x to 0.6.x.
+ */
+try {
+ module.exports = require('../build/Release/canvas');
+} catch (e) { try {
+ module.exports = require('../build/default/canvas');
+} catch (e) {
+ throw e;
+}}
View
@@ -9,7 +9,7 @@
* Module dependencies.
*/
-var canvas = require('../build/default/canvas')
+var canvas = require('./bindings')
, Canvas = canvas.Canvas
, Image = canvas.Image
, cairoVersion = canvas.cairoVersion
View
@@ -9,7 +9,7 @@
* Module dependencies.
*/
-var canvas = require('../build/default/canvas')
+var canvas = require('./bindings')
, Context2d = canvas.CanvasRenderingContext2d
, CanvasGradient = canvas.CanvasGradient
, ImageData = canvas.ImageData
@@ -320,4 +320,4 @@ Context2d.prototype.createImageData = function(width, height){
width = width.width;
}
return new ImageData(new PixelArray(width, height));
-};
+};
View
@@ -9,7 +9,7 @@
* Module dependencies.
*/
-var Canvas = require('../build/default/canvas')
+var Canvas = require('./bindings')
, Image = Canvas.Image;
/**
@@ -57,4 +57,4 @@ Image.prototype.inspect = function(){
+ (this.src ? ' ' + this.src : '')
+ (this.complete ? ' complete' : '')
+ ']';
-};
+};
View
@@ -9,7 +9,7 @@
* Module dependencies.
*/
-var Canvas = require('../build/default/canvas')
+var Canvas = require('./bindings')
, PixelArray = Canvas.CanvasPixelArray;
/**

0 comments on commit 42fce70

Please sign in to comment.