From a33c2bd358dff8fd99cce43094fbcf34da561182 Mon Sep 17 00:00:00 2001 From: "David Humphrey (:humph) david.humphrey@senecacollege.ca" Date: Tue, 18 Feb 2014 11:02:08 -0500 Subject: [PATCH] Fix failing null-byte case in PhantomJS for fs.truncate. Fixes #117 --- src/fs.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/fs.js b/src/fs.js index b80fe0f..18a35b8 100644 --- a/src/fs.js +++ b/src/fs.js @@ -2291,7 +2291,13 @@ define(function(require) { if(error) callback(error); }; FileSystem.prototype.truncate = function(path, length, callback) { + // Follow node.js in allowing the `length` to be optional + if(typeof length === 'function') { + callback = length; + length = 0; + } callback = maybeCallback(callback); + length = typeof length === 'number' ? length : 0; var fs = this; var error = fs.queueOrRun( function() {