Skip to content

Commit

Permalink
process.env.HOME windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Sep 21, 2014
1 parent 4fc2e93 commit 2db47cb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
10 changes: 7 additions & 3 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

exports.HOME = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;

var ui = require('./ui');
var fs = require('graceful-fs');
var path = require('path');
Expand Down Expand Up @@ -714,12 +716,14 @@ exports.parseDependencies = function(dependencies, registry) {





// global config - automatically created and loaded on startup
exports.endpoints = [];
var globalConfigFile = process.env.HOME + path.sep + '.jspm' + path.sep + 'config';
var globalConfigFile = exports.HOME + path.sep + '.jspm' + path.sep + 'config';
function saveGlobalConfig() {
try {
fs.mkdirSync(process.env.HOME + path.sep + '.jspm');
fs.mkdirSync(exports.HOME + path.sep + '.jspm');
}
catch(e) {
if (e.code != 'EEXIST')
Expand All @@ -743,7 +747,7 @@ if (fs.existsSync(globalConfigFile)) {
}
else {
exports.globalConfig = {};
if (process.env.HOME)
if (exports.HOME)
saveGlobalConfig();
}
exports.saveGlobalConfig = saveGlobalConfig;
Expand Down
2 changes: 1 addition & 1 deletion lib/endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ exports.load = function(endpoint) {

try {
// ensure the tmpDir exists
var tmpDir = path.resolve(process.env.HOME, '.jspm', 'tmp-' + endpoint);
var tmpDir = path.resolve(config.HOME, '.jspm', 'tmp-' + endpoint);
if (!fs.existsSync(tmpDir))
fs.mkdirSync(tmpDir);

Expand Down
8 changes: 5 additions & 3 deletions lib/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ var Package = package.Package;
var Promise = require('rsvp').Promise;
var asp = require('rsvp').denodeify;

var config = require('./config');

var ncp = require('ncp');

var path = require('path');
Expand Down Expand Up @@ -64,7 +66,7 @@ exports.link = function(name, dir, force) {
pkg = new Package(fullName);
})
.then(function() {
linkDir = path.resolve(process.env.HOME, '.jspm', 'linked', pkg.endpoint, pkg.exactPackage);
linkDir = path.resolve(config.HOME, '.jspm', 'linked', pkg.endpoint, pkg.exactPackage);
try {
if (fs.existsSync(linkDir)) {
return (force ? Promise.resolve(true) : ui.confirm('`' + pkg.exactName + '` is already linked, are you sure you want to override it?', true))
Expand Down Expand Up @@ -110,7 +112,7 @@ exports.link = function(name, dir, force) {
exports.lookup = function(pkg) {
var packageParts = pkg.package.split('/');
var packagePart = packageParts.pop();
var linkFolder = path.resolve(process.env.HOME, '.jspm', 'linked', pkg.endpoint, packageParts.join('/'));
var linkFolder = path.resolve(config.HOME, '.jspm', 'linked', pkg.endpoint, packageParts.join('/'));

return asp(fs.readdir)(linkFolder)
.then(function(files) {
Expand Down Expand Up @@ -142,7 +144,7 @@ exports.lookup = function(pkg) {
}

exports.symlink = function(pkg, jspmPackages, options, preLoad) {
var linkDir = path.resolve(process.env.HOME, '.jspm', 'linked', pkg.endpoint, pkg.exactPackage);
var linkDir = path.resolve(config.HOME, '.jspm', 'linked', pkg.endpoint, pkg.exactPackage);
var dir = path.resolve(jspmPackages, pkg.endpoint, pkg.exactPackage);
var pjson;

Expand Down
2 changes: 1 addition & 1 deletion lib/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ exports.getCDNPackageJSON = function(fullName, remote) {

// clones / updates github:jspm/registry to ~/.jspm/registry
var registryUpdated;
var registryPath = path.resolve(process.env.HOME, '.jspm/registry');
var registryPath = path.resolve(config.HOME, '.jspm/registry');
exports.updateRegistry = function() {
if (registryUpdated)
return Promise.resolve(registryUpdated);
Expand Down

0 comments on commit 2db47cb

Please sign in to comment.