Skip to content

Commit

Permalink
Continued replacement of process.env.HOME* with os.homedir()
Browse files Browse the repository at this point in the history
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information
rwaldron committed May 30, 2016
1 parent 48177d1 commit 9d88920
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
5 changes: 2 additions & 3 deletions lib/tessel/deploy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// System Objects
var os = require('os');
var path = require('path');

// Third Party Dependencies
Expand All @@ -13,8 +14,6 @@ var Preferences = require('../preferences');
var provision = require('./provision'); // jshint ignore:line
var Tessel = require('./tessel');

var isWindows = process.platform.startsWith('win');

// Used to store local functionality and allow
// exporting those definitions for testing.
var exportables = {};
Expand Down Expand Up @@ -225,7 +224,7 @@ exportables.findProject = function(opts) {
return new Promise((resolve, reject) => {
var single = opts.single;
var file = opts.entryPoint;
var home = process.env[isWindows ? 'USERPROFILE' : 'HOME'];
var home = os.homedir();
var checkConfiguration = false;
var isDirectory = false;

Expand Down
7 changes: 1 addition & 6 deletions test/unit/deployment/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -1553,12 +1553,9 @@ exports['deploy.findProject'] = {
home: function(test) {
test.expect(1);

var key = /^win/.test(process.platform) ? 'USERPROFILE' : 'HOME';
var real = process.env[key];
var fake = path.normalize('/fake/test/home/dir');

process.env[key] = fake;

this.homedir = sandbox.stub(os, 'homedir').returns(fake);
this.lstatSync = sandbox.stub(fs, 'lstatSync', (file) => {
return {
isDirectory: () => {
Expand All @@ -1569,8 +1566,6 @@ exports['deploy.findProject'] = {
});

this.realpathSync = sandbox.stub(fs, 'realpathSync', (arg) => {
process.env[key] = real;

// Ensure that "~" was transformed
test.equal(arg, path.normalize('/fake/test/home/dir/foo'));
test.done();
Expand Down
9 changes: 9 additions & 0 deletions test/unit/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ exports['Preferences.load'] = {
test.done();
});
},

homedir: function(test) {
test.expect(1);

Preferences.load().then(() => {
test.ok(this.exists.firstCall.args[0].startsWith(os.homedir()));
test.done();
});
}
};

exports['Preferences.read'] = {
Expand Down

0 comments on commit 9d88920

Please sign in to comment.