Skip to content

Commit

Permalink
Tilestream starts properly even if HOME is unset, by using os.homedir()
Browse files Browse the repository at this point in the history
  • Loading branch information
okdistribute committed Mar 4, 2018
1 parent 61e85fc commit 3b550d4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion commands/global.bones
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var os = reuqire('os');
var path = require('path');

Bones.Command.options['uiPort'] = {
Expand Down Expand Up @@ -25,7 +26,7 @@ Bones.Command.options['subdomains'] = {
Bones.Command.options['tiles'] = {
'title': 'tiles=[path]',
'description': 'Path to tiles directory.',
'default': path.join(process.env.HOME, 'Documents', 'MapBox', 'tiles')
'default': path.join(os.homedir(), 'Documents', 'MapBox', 'tiles')
};

Bones.Command.options['accesslog'] = {
Expand Down
8 changes: 2 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
#!/usr/bin/env node
var os = require('os');

// increase the libuv threadpool size to 1.5x the number of logical CPUs.
process.env.UV_THREADPOOL_SIZE = Math.ceil(Math.max(4, require('os').cpus().length * 1.5));
process.env.UV_THREADPOOL_SIZE = Math.ceil(Math.max(4, os.cpus().length * 1.5));

process.title = 'tilestream';

if (process.platform === 'win32') {
// HOME is undefined on windows
process.env.HOME = process.env.USERPROFILE;
}

var tilelive = require('tilelive');
require('mbtiles').registerProtocols(tilelive);

Expand Down
5 changes: 4 additions & 1 deletion lib/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
var fs = require('fs');
var os = require('os');
var path = require('path');
var util = require('util');
var existsSync = require('fs').existsSync || require('path').existsSync;

let homedir = os.homedir()

function mkdirpSync(p, mode) {
var ps = path.normalize(p).split('/');
var created = [];
Expand All @@ -20,7 +23,7 @@ module.exports = function(settings, callback) {
try {
fs.statSync(settings.tiles);
} catch (Exception) {
if (!process.env.HOME) {
if (!homedir) {
console.log('Could not locate home directory. Set location manually with the --tiles option.');
process.exit(1);
} else {
Expand Down

0 comments on commit 3b550d4

Please sign in to comment.