Merge pull request #51 from jonathanong/deprecate-write

show deprecation warning for .write()
This commit is contained in:
Lovell Fuller 2014-06-04 10:43:59 +01:00
commit 4ae22b3425
3 changed files with 6 additions and 4 deletions

View File

@ -2,6 +2,7 @@
'use strict'; 'use strict';
var Promise = require('bluebird'); var Promise = require('bluebird');
var deprecate = require('util-deprecate');
var sharp = require('./build/Release/sharp'); var sharp = require('./build/Release/sharp');
var Sharp = function(input) { var Sharp = function(input) {
@ -163,7 +164,7 @@ Sharp.prototype.toFile = function(output, callback) {
}; };
// Deprecated to make way for future stream support - remove in v0.6.0 // Deprecated to make way for future stream support - remove in v0.6.0
Sharp.prototype.write = Sharp.prototype.toFile; Sharp.prototype.write = deprecate(Sharp.prototype.toFile, '.write() is deprecated and will be removed in v0.6.0. Use .toFile() instead.');
Sharp.prototype.toBuffer = function(callback) { Sharp.prototype.toBuffer = function(callback) {
return this._sharp('__input', callback); return this._sharp('__input', callback);

View File

@ -32,7 +32,8 @@
], ],
"dependencies": { "dependencies": {
"nan": "^1.1.2", "nan": "^1.1.2",
"bluebird": "^1.2.4" "bluebird": "^1.2.4",
"util-deprecate": "^1.0.0"
}, },
"devDependencies": { "devDependencies": {
"imagemagick": "^0.1.3", "imagemagick": "^0.1.3",

View File

@ -219,7 +219,7 @@ async.series([
}, },
// Do not enlarge the output if the input width is already less than the output width // Do not enlarge the output if the input width is already less than the output width
function(done) { function(done) {
sharp(inputJpg).resize(2800).withoutEnlargement().write(outputJpg, function(err) { sharp(inputJpg).resize(2800).withoutEnlargement().toFile(outputJpg, function(err) {
if (err) throw err; if (err) throw err;
imagemagick.identify(outputJpg, function(err, features) { imagemagick.identify(outputJpg, function(err, features) {
if (err) throw err; if (err) throw err;
@ -231,7 +231,7 @@ async.series([
}, },
// Do not enlarge the output if the input height is already less than the output height // Do not enlarge the output if the input height is already less than the output height
function(done) { function(done) {
sharp(inputJpg).resize(null, 2300).withoutEnlargement().write(outputJpg, function(err) { sharp(inputJpg).resize(null, 2300).withoutEnlargement().toFile(outputJpg, function(err) {
if (err) throw err; if (err) throw err;
imagemagick.identify(outputJpg, function(err, features) { imagemagick.identify(outputJpg, function(err, features) {
if (err) throw err; if (err) throw err;