diff --git a/commands/global.bones b/commands/global.bones index aefdcd4..54dfb94 100644 --- a/commands/global.bones +++ b/commands/global.bones @@ -1,3 +1,4 @@ +var os = reuqire('os'); var path = require('path'); Bones.Command.options['uiPort'] = { @@ -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'] = { diff --git a/index.js b/index.js index ff4d83a..2e8a0fe 100755 --- a/index.js +++ b/index.js @@ -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); diff --git a/lib/bootstrap.js b/lib/bootstrap.js index 89ec9d0..dfaba82 100644 --- a/lib/bootstrap.js +++ b/lib/bootstrap.js @@ -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 = []; @@ -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 {