Permalink
Browse files

Better util/sys fallback with try/catch instead of version magic.

  • Loading branch information...
1 parent c83c285 commit bf806a0be3b07f5858aa55390b6792fe1bf07f5e @mranney mranney committed Nov 16, 2011
Showing with 10 additions and 6 deletions.
  1. +10 −6 lib/util.js
View
@@ -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;

0 comments on commit bf806a0

Please sign in to comment.