On 12/11/2016 06:52 PM, Christian Seiler wrote:
> I've attached an updated use-os-homedir.patch that does this (including
> the removal of the require.resolve() line above),

And I just noticed that I forgot a semicolon after a line (not
critical, because javascript doesn't require it, but stylistically
it's not nice) and had some trailing whitespace. I've updated the
patch and attached it.

Regards,
Christian
use os.homedir instead of user-home

--- a/index.js
+++ b/index.js
@@ -26,7 +26,7 @@ function fail (err) {
 }
 
 function openConfig (cb) {
-  var userHome = require('user-home');
+  var userHome = os.homedir();
   if (!userHome) {
     return tryOpenConfig(path.join(os.tmpdir(), configfile), cb);
   }
--- a/test.js
+++ b/test.js
@@ -7,6 +7,8 @@ const expect = require('chai').expect;
 
 const env = process.env;
 
+const old_os_homedir = os.homedir;
+
 function eraseHome() {
   delete env.HOME;
   delete env.USERPROFILE;
@@ -16,6 +18,8 @@ function eraseHome() {
   delete env.USER;
   delete env.LNAME;
   delete env.USERNAME;
+
+  os.homedir = function() { return null; };
 }
 
 function setTemp(dir) {
@@ -24,7 +28,7 @@ function setTemp(dir) {
 
 function cleanup () {
   var v8flags = require('./');
-  var userHome = require('user-home');
+  var userHome = os.homedir();
   if (userHome === null) userHome = __dirname;
 
   var files = [
@@ -37,7 +41,7 @@ function cleanup () {
     } catch (e) {}
   });
 
-  delete require.cache[require.resolve('user-home')];
+  os.homedir = old_os_homedir;
   delete process.versions.electron;
 }
 
@@ -47,7 +51,7 @@ describe('v8flags', function () {
 
   it('should cache and call back with the v8 flags for the running process', function (done) {
     var v8flags = require('./');
-    var configfile = path.resolve(require('user-home'), v8flags.configfile);
+    var configfile = path.resolve(os.homedir(), v8flags.configfile);
     v8flags(function (err, flags) {
       expect(flags).to.be.a('array');
       expect(fs.existsSync(configfile)).to.be.true;
@@ -62,7 +66,7 @@ describe('v8flags', function () {
 
   it('should not append the file when multiple calls happen concurrently and the config file does not yet exist', function (done) {
     var v8flags = require('./');
-    var configfile = path.resolve(require('user-home'), v8flags.configfile);
+    var configfile = path.resolve(os.homedir(), v8flags.configfile);
     async.parallel([v8flags, v8flags, v8flags], function (err, result) {
       v8flags(function (err2, res) {
         done();
-- 
Pkg-javascript-devel mailing list
Pkg-javascript-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-javascript-devel

Reply via email to