diff --git a/index.js b/index.js
index d4e4706..b710c4e 100644
--- a/index.js
+++ b/index.js
@@ -9,12 +9,11 @@ var homedir = require('homedir-polyfill');
 var path = require('path');
 
 module.exports = function expandTilde(filepath) {
-  var home = homedir();
-
   if (filepath.charCodeAt(0) === 126 /* ~ */) {
     if (filepath.charCodeAt(1) === 43 /* + */) {
       return path.join(process.cwd(), filepath.slice(2));
     }
+    const home = homedir();
     return home ? path.join(home, filepath.slice(1)) : filepath;
   }