From bf806a0be3b07f5858aa55390b6792fe1bf07f5e Mon Sep 17 00:00:00 2001 From: Matt Ranney Date: Wed, 16 Nov 2011 10:57:02 -1000 Subject: [PATCH] Better util/sys fallback with try/catch instead of version magic. --- lib/util.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/util.js b/lib/util.js index 599c97af66..fc255ae953 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1,7 +1,11 @@ -// Support for very old versions of node. At some point, we should abandon this. -var minor = process.versions.node.split('.')[1]; -if (minor > 2) { - module.exports = require("util"); -} else { - module.exports = require("sys"); +// Support for very old versions of node where the module was called "sys". At some point, we should abandon this. + +var util; + +try { + util = require("util"); +} catch (err) { + util = require("sys"); } + +module.exports = util;