Browse Source

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.
v1.x
Nathan Rajlich 13 years ago
parent
commit
42fce70a89
  1. 10
      lib/bindings.js
  2. 2
      lib/canvas.js
  3. 4
      lib/context2d.js
  4. 4
      lib/image.js
  5. 2
      lib/pixelarray.js

10
lib/bindings.js

@ -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;
}}

2
lib/canvas.js

@ -9,7 +9,7 @@
* Module dependencies. * Module dependencies.
*/ */
var canvas = require('../build/default/canvas') var canvas = require('./bindings')
, Canvas = canvas.Canvas , Canvas = canvas.Canvas
, Image = canvas.Image , Image = canvas.Image
, cairoVersion = canvas.cairoVersion , cairoVersion = canvas.cairoVersion

4
lib/context2d.js

@ -9,7 +9,7 @@
* Module dependencies. * Module dependencies.
*/ */
var canvas = require('../build/default/canvas') var canvas = require('./bindings')
, Context2d = canvas.CanvasRenderingContext2d , Context2d = canvas.CanvasRenderingContext2d
, CanvasGradient = canvas.CanvasGradient , CanvasGradient = canvas.CanvasGradient
, ImageData = canvas.ImageData , ImageData = canvas.ImageData
@ -320,4 +320,4 @@ Context2d.prototype.createImageData = function(width, height){
width = width.width; width = width.width;
} }
return new ImageData(new PixelArray(width, height)); return new ImageData(new PixelArray(width, height));
}; };

4
lib/image.js

@ -9,7 +9,7 @@
* Module dependencies. * Module dependencies.
*/ */
var Canvas = require('../build/default/canvas') var Canvas = require('./bindings')
, Image = Canvas.Image; , Image = Canvas.Image;
/** /**
@ -57,4 +57,4 @@ Image.prototype.inspect = function(){
+ (this.src ? ' ' + this.src : '') + (this.src ? ' ' + this.src : '')
+ (this.complete ? ' complete' : '') + (this.complete ? ' complete' : '')
+ ']'; + ']';
}; };

2
lib/pixelarray.js

@ -9,7 +9,7 @@
* Module dependencies. * Module dependencies.
*/ */
var Canvas = require('../build/default/canvas') var Canvas = require('./bindings')
, PixelArray = Canvas.CanvasPixelArray; , PixelArray = Canvas.CanvasPixelArray;
/** /**

Loading…
Cancel
Save